I am updating some code in a servlet that previously accepted a UTF-8 file and now gets its input from a textarea.
The problem: For any unicode character in the string the representation is 'ה' while a comma for example will remain ',' . Therefore, when in.read() is called instead of returning the number '1492' it returns first '&' then '#' then '1' , 4 ,9 ,2 etc. each char at a singe time.
Any suggestions of methods that will handle the string differently so it returns a number?
Thanks a load.
Old Code------------------------
This successfully gives me the integer of the UTF8 file which I then use for a comparison....
int would be equal to for example '1492'.
I replaced the code with ----------------------------------
-----
with input file being a String returned by the textarea.
The problem: For any unicode character in the string the representation is 'ה' while a comma for example will remain ',' . Therefore, when in.read() is called instead of returning the number '1492' it returns first '&' then '#' then '1' , 4 ,9 ,2 etc. each char at a singe time.
Any suggestions of methods that will handle the string differently so it returns a number?
Thanks a load.
Old Code------------------------
Code:
int ch; //unicode char read from file
try{//try 1
FileInputStream fis = new FileInputStream(userInputFile);
InputStreamReader isr = new InputStreamReader(fis,"UTF8");
BufferedReader in = new BufferedReader(isr);
while ((ch = in.read()) > -1) {
int would be equal to for example '1492'.
I replaced the code with ----------------------------------
Code:
int ch; //unicode char read from file
try{//try 1
StringReader isr = new StringReader(InputFile);
BufferedReader in = new BufferedReader(isr);
while ((ch = in.read()) > -1) {
key = new Mapping();
key.numChar = ch;
location = Arrays.binarySearch(MapArray, key , new Comparator() {
with input file being a String returned by the textarea.