forked from kalmar/DALGLI0
charset update 2
This commit is contained in:
parent
841b8b4590
commit
cdb246b734
@ -1,14 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="5f8a3521-157f-4adb-a0ab-dc99bbf14aa0" name="Default" comment="small code refactor">
|
<list default="true" id="5f8a3521-157f-4adb-a0ab-dc99bbf14aa0" name="Default" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/description.html" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/project-template.xml" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/out/production/Zadanie-03/com/tylkowski/crc/CrcTask.class" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/out/production/Zadanie-03/com/tylkowski/crc/Main.class" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/com/tylkowski/crc/CrcTask.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/tylkowski/crc/CrcTask.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/com/tylkowski/crc/CrcTask.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/tylkowski/crc/CrcTask.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/com/tylkowski/crc/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/tylkowski/crc/Main.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/com/tylkowski/crc/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/tylkowski/crc/Main.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
@ -25,8 +19,8 @@
|
|||||||
<file leaf-file-name="Main.java" pinned="false" current-in-tab="true">
|
<file leaf-file-name="Main.java" pinned="false" current-in-tab="true">
|
||||||
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/Main.java">
|
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/Main.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="238">
|
<state relative-caret-position="255">
|
||||||
<caret line="14" column="57" selection-start-line="14" selection-start-column="51" selection-end-line="14" selection-end-column="57" />
|
<caret line="15" column="9" lean-forward="true" selection-start-line="15" selection-start-column="9" selection-end-line="15" selection-end-column="9" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
@ -34,8 +28,8 @@
|
|||||||
<file leaf-file-name="CrcTask.java" pinned="false" current-in-tab="false">
|
<file leaf-file-name="CrcTask.java" pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/CrcTask.java">
|
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/CrcTask.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="102">
|
<state relative-caret-position="178">
|
||||||
<caret line="13" column="22" selection-start-line="13" selection-start-column="22" selection-end-line="13" selection-end-column="22" />
|
<caret line="44" column="9" lean-forward="true" selection-start-line="44" selection-start-column="9" selection-end-line="44" selection-end-column="9" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="imports" expanded="true" />
|
<element signature="imports" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
@ -66,6 +60,9 @@
|
|||||||
<find>chunk</find>
|
<find>chunk</find>
|
||||||
<find>toBin</find>
|
<find>toBin</find>
|
||||||
<find>toBinaryStr</find>
|
<find>toBinaryStr</find>
|
||||||
|
<find>swap</find>
|
||||||
|
<find>letter</find>
|
||||||
|
<find>lol</find>
|
||||||
</findStrings>
|
</findStrings>
|
||||||
</component>
|
</component>
|
||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
@ -74,8 +71,8 @@
|
|||||||
<component name="IdeDocumentHistory">
|
<component name="IdeDocumentHistory">
|
||||||
<option name="CHANGED_PATHS">
|
<option name="CHANGED_PATHS">
|
||||||
<list>
|
<list>
|
||||||
<option value="$PROJECT_DIR$/src/com/tylkowski/crc/CrcTask.java" />
|
|
||||||
<option value="$PROJECT_DIR$/src/com/tylkowski/crc/Main.java" />
|
<option value="$PROJECT_DIR$/src/com/tylkowski/crc/Main.java" />
|
||||||
|
<option value="$PROJECT_DIR$/src/com/tylkowski/crc/CrcTask.java" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
@ -96,6 +93,8 @@
|
|||||||
<foldersAlwaysOnTop value="true" />
|
<foldersAlwaysOnTop value="true" />
|
||||||
</navigator>
|
</navigator>
|
||||||
<panes>
|
<panes>
|
||||||
|
<pane id="PackagesPane" />
|
||||||
|
<pane id="AndroidView" />
|
||||||
<pane id="ProjectPane">
|
<pane id="ProjectPane">
|
||||||
<subPane>
|
<subPane>
|
||||||
<expand>
|
<expand>
|
||||||
@ -118,9 +117,7 @@
|
|||||||
<select />
|
<select />
|
||||||
</subPane>
|
</subPane>
|
||||||
</pane>
|
</pane>
|
||||||
<pane id="AndroidView" />
|
|
||||||
<pane id="Scope" />
|
<pane id="Scope" />
|
||||||
<pane id="PackagesPane" />
|
|
||||||
</panes>
|
</panes>
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">
|
<component name="PropertiesComponent">
|
||||||
@ -144,8 +141,7 @@
|
|||||||
<configuration name="Main" type="Application" factoryName="Application" temporary="true">
|
<configuration name="Main" type="Application" factoryName="Application" temporary="true">
|
||||||
<option name="MAIN_CLASS_NAME" value="com.tylkowski.crc.Main" />
|
<option name="MAIN_CLASS_NAME" value="com.tylkowski.crc.Main" />
|
||||||
<module name="Zadanie-03" />
|
<module name="Zadanie-03" />
|
||||||
<option name="PROGRAM_PARAMETERS" value=""1" "a"" />
|
<option name="PROGRAM_PARAMETERS" value=""2" "b"" />
|
||||||
<option name="VM_PARAMETERS" value="-Dfile.encoding=latin-1" />
|
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
||||||
<RunnerSettings RunnerId="Run" />
|
<RunnerSettings RunnerId="Run" />
|
||||||
<ConfigurationWrapper RunnerId="Run" />
|
<ConfigurationWrapper RunnerId="Run" />
|
||||||
@ -187,7 +183,8 @@
|
|||||||
<workItem from="1529407679397" duration="19000" />
|
<workItem from="1529407679397" duration="19000" />
|
||||||
<workItem from="1529409635196" duration="1437000" />
|
<workItem from="1529409635196" duration="1437000" />
|
||||||
<workItem from="1529428699866" duration="20522000" />
|
<workItem from="1529428699866" duration="20522000" />
|
||||||
<workItem from="1529482084631" duration="5516000" />
|
<workItem from="1529482084631" duration="5831000" />
|
||||||
|
<workItem from="1529497353540" duration="2850000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="project started">
|
<task id="LOCAL-00001" summary="project started">
|
||||||
<created>1529359475020</created>
|
<created>1529359475020</created>
|
||||||
@ -224,11 +221,18 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1529450003665</updated>
|
<updated>1529450003665</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="6" />
|
<task id="LOCAL-00006" summary="charset update">
|
||||||
|
<created>1529487959831</created>
|
||||||
|
<option name="number" value="00006" />
|
||||||
|
<option name="presentableId" value="LOCAL-00006" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1529487959831</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="7" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TimeTrackingManager">
|
<component name="TimeTrackingManager">
|
||||||
<option name="totallyTimeSpent" value="41722000" />
|
<option name="totallyTimeSpent" value="44887000" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ToolWindowManager">
|
<component name="ToolWindowManager">
|
||||||
<frame x="-8" y="-8" width="1382" height="744" extended-state="6" />
|
<frame x="-8" y="-8" width="1382" height="744" extended-state="6" />
|
||||||
@ -244,11 +248,11 @@
|
|||||||
<window_info anchor="right" id="Maven Projects" order="3" />
|
<window_info anchor="right" id="Maven Projects" order="3" />
|
||||||
<window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
|
<window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
|
||||||
<window_info anchor="bottom" id="Version Control" order="7" />
|
<window_info anchor="bottom" id="Version Control" order="7" />
|
||||||
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.43069306" />
|
<window_info anchor="bottom" id="Run" order="2" weight="0.38118812" />
|
||||||
<window_info anchor="bottom" id="Terminal" order="7" />
|
<window_info anchor="bottom" id="Terminal" order="7" />
|
||||||
<window_info id="Capture Tool" order="2" />
|
<window_info id="Capture Tool" order="2" />
|
||||||
<window_info id="Designer" order="2" />
|
<window_info id="Designer" order="2" />
|
||||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.16414523" />
|
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.16641453" />
|
||||||
<window_info anchor="right" id="Database" order="3" />
|
<window_info anchor="right" id="Database" order="3" />
|
||||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||||
@ -276,9 +280,27 @@
|
|||||||
<MESSAGE value="encode added!" />
|
<MESSAGE value="encode added!" />
|
||||||
<MESSAGE value="decode added!" />
|
<MESSAGE value="decode added!" />
|
||||||
<MESSAGE value="small code refactor" />
|
<MESSAGE value="small code refactor" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="small code refactor" />
|
<MESSAGE value="charset update" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="charset update" />
|
||||||
</component>
|
</component>
|
||||||
<component name="editorHistoryManager">
|
<component name="editorHistoryManager">
|
||||||
|
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/Main.java">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="374">
|
||||||
|
<caret line="22" lean-forward="true" selection-start-line="22" selection-end-line="22" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/CrcTask.java">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="2856">
|
||||||
|
<caret line="170" selection-start-line="170" selection-end-line="170" selection-end-column="50" />
|
||||||
|
<folding>
|
||||||
|
<element signature="imports" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/Main.java">
|
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/Main.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="204">
|
<state relative-caret-position="204">
|
||||||
@ -366,10 +388,24 @@
|
|||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry file="jar://C:/Program Files/Java/jdk1.8.0_77/src.zip!/java/lang/System.java">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="329">
|
||||||
|
<caret line="494" column="24" selection-start-line="494" selection-start-column="24" selection-end-line="494" selection-end-column="24" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
<entry file="jar://C:/Program Files/Java/jdk1.8.0_77/src.zip!/java/util/Arrays.java">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="278">
|
||||||
|
<caret line="3556" column="19" selection-start-line="3556" selection-start-column="19" selection-end-line="3556" selection-end-column="19" />
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/CrcTask.java">
|
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/CrcTask.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="102">
|
<state relative-caret-position="178">
|
||||||
<caret line="13" column="22" selection-start-line="13" selection-start-column="22" selection-end-line="13" selection-end-column="22" />
|
<caret line="44" column="9" lean-forward="true" selection-start-line="44" selection-start-column="9" selection-end-line="44" selection-end-column="9" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="imports" expanded="true" />
|
<element signature="imports" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
@ -378,8 +414,8 @@
|
|||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/Main.java">
|
<entry file="file://$PROJECT_DIR$/src/com/tylkowski/crc/Main.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="238">
|
<state relative-caret-position="255">
|
||||||
<caret line="14" column="57" selection-start-line="14" selection-start-column="51" selection-end-line="14" selection-end-column="57" />
|
<caret line="15" column="9" lean-forward="true" selection-start-line="15" selection-start-column="9" selection-end-line="15" selection-end-column="9" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -18,10 +18,10 @@ class CrcTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setEncoding() throws NoSuchFieldException, IllegalAccessException {
|
private void setEncoding() throws NoSuchFieldException, IllegalAccessException {
|
||||||
System.setProperty("file.encoding","ISO-8859-1");
|
System.setProperty("file.encoding", "ISO-8859-1");
|
||||||
Field charset = Charset.class.getDeclaredField("defaultCharset");
|
Field charset = Charset.class.getDeclaredField("defaultCharset");
|
||||||
charset.setAccessible(true);
|
charset.setAccessible(true);
|
||||||
charset.set(null,null);
|
charset.set(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatMessage(String message) {
|
private String formatMessage(String message) {
|
||||||
@ -65,8 +65,6 @@ class CrcTask {
|
|||||||
remainder = removeUnecessaryZeros(remainder);
|
remainder = removeUnecessaryZeros(remainder);
|
||||||
messageAsShortArray = createMessageFromRemainderAndPartFromOldMessage(remainder, messageAsShortArray);
|
messageAsShortArray = createMessageFromRemainderAndPartFromOldMessage(remainder, messageAsShortArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -111,7 +109,6 @@ class CrcTask {
|
|||||||
private char getCharFromShortArray(short[] piece, int from, int to) {
|
private char getCharFromShortArray(short[] piece, int from, int to) {
|
||||||
short[] sign = Arrays.copyOfRange(piece, from, to);
|
short[] sign = Arrays.copyOfRange(piece, from, to);
|
||||||
int character = Integer.parseInt(shortArrayToBinaryString(sign), 2);
|
int character = Integer.parseInt(shortArrayToBinaryString(sign), 2);
|
||||||
// System.out.println(character);
|
|
||||||
return (char) character;
|
return (char) character;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,30 +162,23 @@ class CrcTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String letterToBinaryString(char letter) {
|
private String letterToBinaryString(char letter) {
|
||||||
// System.out.println("lt: " + letter + " " + (int) letter);
|
|
||||||
int a = (int) letter;
|
int a = (int) letter;
|
||||||
// if (a == 63) a = 157;
|
|
||||||
System.out.println("letter in int: " + a);
|
|
||||||
|
|
||||||
StringBuilder binaryString = new StringBuilder(Integer.toBinaryString(a));
|
StringBuilder binaryString = new StringBuilder(Integer.toBinaryString(a));
|
||||||
|
|
||||||
while (binaryString.length() % 8 != 0) {
|
while (binaryString.length() % 8 != 0) {
|
||||||
binaryString.insert(0, "0");
|
binaryString.insert(0, "0");
|
||||||
}
|
}
|
||||||
// System.out.println("bs" + binaryString.toString());
|
|
||||||
return binaryString.toString();
|
return binaryString.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean decode(String encodedString) {
|
boolean decode(String encodedString) {
|
||||||
encodedString = toBinaryString(encodedString);
|
encodedString = toBinaryString(encodedString);
|
||||||
encodedString = fillPolyTo8(encodedString);
|
encodedString = fillPoly(encodedString);
|
||||||
short[] encodedShortArray = convertBinaryStringToShortArray(encodedString);
|
short[] encodedShortArray = convertBinaryStringToShortArray(encodedString);
|
||||||
encodedShortArray = swapPolynomialValues(encodedShortArray);
|
encodedShortArray = swapPolynomialValues(encodedShortArray);
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!shortArrayContains(encodedShortArray, 1)) {
|
if (!shortArrayContains(encodedShortArray, 1)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encodedShortArray[0] == 0) {
|
if (encodedShortArray[0] == 0) {
|
||||||
encodedShortArray = Arrays.copyOfRange(encodedShortArray, 1, encodedShortArray.length);
|
encodedShortArray = Arrays.copyOfRange(encodedShortArray, 1, encodedShortArray.length);
|
||||||
} else {
|
} else {
|
||||||
@ -208,7 +198,6 @@ class CrcTask {
|
|||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
for (int i = 0; i < encodedString.length(); i++) {
|
for (int i = 0; i < encodedString.length(); i++) {
|
||||||
stringBuilder.append(letterToBinaryString(encodedString.charAt(i)));
|
stringBuilder.append(letterToBinaryString(encodedString.charAt(i)));
|
||||||
|
|
||||||
}
|
}
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
@ -222,7 +211,7 @@ class CrcTask {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String fillPolyTo8(String encodedString) {
|
private String fillPoly(String encodedString) {
|
||||||
StringBuilder stringBuilder = new StringBuilder(encodedString);
|
StringBuilder stringBuilder = new StringBuilder(encodedString);
|
||||||
while (stringBuilder.length() % 8 != 0) {
|
while (stringBuilder.length() % 8 != 0) {
|
||||||
stringBuilder.insert(0, "0");
|
stringBuilder.insert(0, "0");
|
||||||
|
@ -3,10 +3,10 @@ package com.tylkowski.crc;
|
|||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
|
public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
|
||||||
// use valid character encoding ISO-8859-1
|
// in command line type "1" for mode and "b" for message
|
||||||
// in command line type "1" for mode and "a" for message
|
// example "1" "b" -> this will encode string "b" and return FCS
|
||||||
//example "1" "a" -> this will encode string "a" and return FCS
|
// example "2" "bXY" -> this will decode string "bXY" and return true if it is valid or false if not
|
||||||
// example "2" "abc" -> this will decode string "abc" and return true if it is valid or false if not
|
// X and Y - 1 and 2 character of FCS
|
||||||
CrcTask crcTask = new CrcTask(args[1], args[1]);
|
CrcTask crcTask = new CrcTask(args[1], args[1]);
|
||||||
if(args[0].equals("1")) {
|
if(args[0].equals("1")) {
|
||||||
//create FCS
|
//create FCS
|
||||||
|
Loading…
Reference in New Issue
Block a user