Issues with character encoding please help?

by Moto » Wed, 21 Apr 2010 12:10:17 GMT


Sponsored Links
 I get an array of bytes and I convert that to a String in the
following way:
blockString = new String(tagBlock);

The results are good for english and some other languages but Russian,
Spanish, Chinese, and many others aren't displayed properly...  The
only way to diplay correctly is to find the correct encoding and
decode the language like this:
blockString = new String(tagBlock,"ISO8859_1");

But how can I do this better?  How can I not have to worry about
string encoding?  It's turning out to be a problem back in Japan and
other countries with my app :(

Thanks for any help!
-Moto!

--



Issues with character encoding please help?

by Moto » Wed, 21 Apr 2010 19:47:27 GMT


 I'm sure I'm doing something wrong!?



>


Sponsored Links


Issues with character encoding please help?

by Moto » Thu, 22 Apr 2010 08:42:10 GMT


 I guess no one runs into this kind of issues...???




> >



Issues with character encoding please help?

by Bob Kerns » Thu, 22 Apr 2010 15:09:27 GMT


 No, it's just that I've already told everyone else on the planet (it
seems) not to do this! I've been crusading on this for decades... :=)

Do not ever use the String(byte[]) constructor.

Do not ever pass up an opportunity to explicitly supply a character
encoding.

Always use UTF-8 when you have control over the encoding. But Never,
ever, leave it to the platform default. You must always find out the
encoding somewhere.

If it really is just a bunch of bytes of unknown encoding, and you
can't change that, then you will need to allow the user to make an
alternative selection -- but start with UTF-8 as the default if at all
possible.

Nobody, anywhere, should be using anything but UTF-8 for new data
these days. The world has moved far beyond all these petty national
encodings.

So the first thing is to ask -- where do these bytes come from? If
they're not already in UTF-8, can I change something to get them in
UTF-8? If not, can I get the supplier of these bytes to tell me what
encoding they're in (such as the Content-Type: HTTP file)? If not, how
can I let the user tell me the encoding and character set, if I guess
wrong?





> > >



Other Threads

1. DNS woes with the emulator

My emulator (1.5) can't do DNS resolution.  I'm running it on my Linux
computer.  My Linux computer has no problems with name resolution and
has everything it needs in /etc/resolv.conf.

According to the manual, the emulator is supposed to use the resolvers
in /etc/resolv.conf but it doesn't appear to be doing it.  It also
says I can use a command line like this:

emulator -avd my_android1.5 -dns-server 192.168.1.2

to specify a DNS server, but that gives me:

### WARNING: could not add DNS server '192.168.1.2' to the network
stack
### WARNING: will use system default DNS server

which doesn't do me much good.

This seems really bizarre.  I've seen other posts with people having
DNS problems in Android but haven't seen any referring to that error.
The emulator documentation clearly says, use that command line
argument to specify a server, and that is clearly a valid IP address
of a server.

Any ideas?

Thanks
--~--~---------~--~----~------------~-------~--~----~

2. Creating a new dictionary for spell correction and word completion

Hi,

I'd like to develop a new dictionary for spell correction and word
completation for keyboard..

I'm brazilian and Android doesnt have a pt_BR dictionary..

Someone can help me with witch class, or resources I have to create
for this?

Also, I'd like to create a new Keyboard language too.


thanks!

--~--~---------~--~----~------------~-------~--~----~

3. Proxy support not working in Android 1.6 emulator

4. What is the intended usage of the "Next" and "Done" keys on the soft keyboard

5. Salam kenal & WTA cara backup contact HTC Magic

6. How to create Image filter based animations ; Android Animations

7. Local speed at gps location sometimes reported wrong on G1