Home Help Search Login Register


J2meForums  |  General Category  |  Programming (Moderators: mikkom, shendley)  |  Topic: InputStreamReader problem « previous next »
Pages: [1] Print
Author

InputStreamReader problem

 (Read 65 times)
lesomuzik
New user
*
Posts: 2



View Profile
InputStreamReader problem
« on: July 28, 2010, 08:51:48 pm »

Hello,
I'm trying to load special characters (special letters for Central European contries like č,ď,ň,ľ etc.) from .txt file in resources. In WTK emulator I get nice characters, but in my phones (Nokia 3120, Sony Ericsson k530i) I get different characters. I tried

Code:
InputStream is = getClass( ).getResourceAsStream(filePath);
InputStreamReader r; = new InputStreamReader(is);

while ((count = r.read(buffer, 0, buffer.length)) > -1)
{
sb.append(buffer, 0, count);
}
str = sb.toString();

As I said, works great in WTK, but in phones doesn't work. Note, that my phones can write these characters, but they are not able to read them from file.

Later I tried InputStreamReader.read:int and I found, that those special characters are coded in 2 bytes. WTK reads these 2 bytes together(as 1 int, value is over 256), but phones read them seperately and I get 2 bytes (value < 256) instead of one int.

Thanks for all ideas Smiley
Logged
lesomuzik
New user
*
Posts: 2



View Profile
Re: InputStreamReader problem
« Reply #1 on: August 01, 2010, 03:40:19 pm »

I solved it :-)

Code:
InputStream is = getClass( ).getResourceAsStream(filePath);
InputStreamReader r = new InputStreamReader(is,"UTF-8");
Logged
Pages: [1] Print 
J2meForums  |  General Category  |  Programming (Moderators: mikkom, shendley)  |  Topic: InputStreamReader problem « previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP J2meForums | Powered by SMF 1.0.8.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!