Re: How to get NLS characters from a btye stream?

Discussion in 'Java' started by Ingo Pakleppa - ingo at kkeane dot com, Jul 31, 2003.

  1. You may want to look into the java.io.InputStreamReader class, and related
    classes, to convert byte arrays into strings. Then manipulate the
    characters, rather than the bytes in the byte array, and eventually use an
    OutputStreamWriter to create the new byte array.

    On Thu, 31 Jul 2003 03:58:02 -0700, wing wrote:

    > Dear all,
    >
    > I have a byte array which is encoded in UTF8 which is generated by
    > str.getBytes("UTF8") where the str is chinese characters.
    >
    > How could I cut the byte array in character boundary such that I could
    > use String(bytes[], "UTF8") to construct back the correspondng String
    > without losing any bytes?
    >
    > For example, says, I have 3 chinese character ABC where in UTF8, A is
    > 3-byte-long, B is 4-byte-long and C is 3-byte-long. Is there any API to
    > find that 7 is a character boundary such that I could use the first 7
    > bytes to construct AB without losing bytes?
    >
    > Thanks in advance for inputs and advices.
    >
    > Wing


    --
    Keep American Families united! Support H.R. 539 and H.R. 832
    For more information, see http://www.kkeane.com/lobbyspousal-faq.shtml
     
    Ingo Pakleppa - ingo at kkeane dot com, Jul 31, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. johnny bb
    Replies:
    1
    Views:
    2,104
    steve
    Oct 8, 2005
  2. Rhino
    Replies:
    14
    Views:
    7,520
    Chris Uppal
    Dec 14, 2005
  3. Replies:
    9
    Views:
    643
    Alex Buell
    Apr 27, 2006
  4. Steven D'Aprano

    Unicode characters in btye-strings

    Steven D'Aprano, Mar 12, 2010, in forum: Python
    Replies:
    5
    Views:
    432
    Martin v. Loewis
    Mar 12, 2010
  5. Replies:
    0
    Views:
    108
Loading...

Share This Page