How do I know that there are double-byte characters in s String?

Hi!
If I have a String that contain English and Chinese words,
How do I know that the String contain double-byte characters(Chinese words)?
Following is my method and the problem I suffered...
String A = "test(double-byte chinese)test";
byte B[] = A.getBytes();
if(A.length() != B.length)
System.out.print("String contains double-byte words");
else
System.out.print("String does not contain double-byte words");
If the String contains Chinese words,then A.length() will be smaller than B.length...
I run the program on Window NT workstation(Tradtional Chinese version) and it works...
Then I run the same program on Redhat 6.0(English version),
but the result was not the same as running on NT...
because A.length() always equal to B.length...
I guess that's because of Charset of OS...
But I don't know how to set the Charset of Linux...
Does anybody have other solution to my problem?
Any suggestion will be very appreciate!

A String is always in Unicode. You cannot see what kind of character is in the string unless you compare with the Unicode range of charcters. E.g. 3400-4DB5 is CJKUnified Ideographs extension A. Then you at least know that is is not Latin-1 or other.
Klint

Similar Messages

  • Software update on iMac. Trying to update software I get message "an error has occurred. the request has been timed out" how do i know if there are updates?

    Am trying to update software through "Software Update" on my iMac (latest Lion operating system).
    I keep getting message "An error has occurred. The request timed out"
    How do I know if there are software dates available to down load.
    Ernie

    Two things, bushmanernie (love the name)
    First what version of Lion are you running and have you downloaded any Combo updates since you installed it.
    Second; I see you only have 10.6.2 in your profile.   You might like to update it.
    I don't have Lion myself but I'm guessing you don't have the very latest version.  You can check what should be available through the opening Apple support page > downloads.

  • Double byte characters in a String - Help needed

    Hi All,
    Can anyone tell me how to find the presence of a double byte ( Japanese ) character in a String. I need to check whether the String contains a Japanese character or not. Thanx in advance.
    Ramya

    /** returns true if the String s contains any "double-byte" characters */
    public boolean containsDoubleByte(String s) {
      for (int i=0; i<s.length(); i++) {
        if (isDoubleByte(s.charAt(i)) {
          return true;
      return false;
    /** returns true if the char c is a double-byte character */
    public boolean isJapanese(char c) {
      if (c >= '\u0100' && c<='\uffff') return true;
      return false;
    // simpler:  return c>'\u00ff';
    /** returns true if the String s contains any Japanese characters */
    public boolean containsJapanese(String s) {
      for (int i=0; i<s.length(); i++) {
        if (isJapanese(s.charAt(i)) {
          return true;
      return false;
    /** returns true if the char c is a Japanese character. */
    public boolean isJapanese(char c) {
      // katakana:
      if (c >= '\u30a0' && c<='\u30ff') return true;
      // hiragana
      if (c >= '\u3040' && c<='\u309f') return true;
      // CJK Unified Ideographs
      if (c >= '\u4e00' && c<='\u9fff') return true;
      // CJK symbols & punctuation
      if (c >= '\u3000' && c<='\u303f') return true;
      // KangXi (kanji)
      if (c >= '\u2f00' && c<='\u2fdf') return true;
      // KanBun
      if (c >= '\u3190' && c <='\u319f') return true;
      // CJK Unified Ideographs Extension A
      if (c >= '\u3400' && c <='\u4db5') return true;
      // CJK Compatibility Forms
      if (c >= '\ufe30' && c <='\ufe4f') return true;
      // CJK Compatibility
      if (c >= '\u3300' && c <='\u33ff') return true;
      // CJK Radicals Supplement
      if (c >= '\u2e80' && c <='\u2eff') return true;
      // other character..
      return false;
    /* NB CJK Unified Ideographs Extension B not supported with 16-bit unicode. Source: http://www.alanwood.net/unicode */
    }

  • How can i know that servers are up and running?

    hello everyone...
    i have a distributed application which does the following.. a client submits a job which is passed from one server to another and after some processing on each server the job is returned back to the client.. the thing is that i want to make the whole application more reliable... how can i found out if the next server that i am going to submit the job is up and running?
    the client has decided the order of the servers that should be followed but when a server processes the job another one may "die..." and i am telling you that because i cannot check if the cast of the objectReference fails when i make the list on the client...
    is there any function that i can call to the orb and find that out ?
    thxxxxx
    ps. i am using java and corba orb

    hmm... when i reproduce the situation i get the following
    15 &#9472;&#943;&#902; 2006 2:39:47 &#905;&#905; com.sun.corba.se.impl.transport.SocketOrChannelConnection
    Impl <init>
    WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR
    _TEXT; hostname: 10.34.153.11; port: 2945"
    org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 201  completed: No
            at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(U
    nknown Source)
            at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(U
    nknown Source)
            at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(
    Unknown Source)
            at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(
    Unknown Source)
            at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.create
    Connection(Unknown Source)
            at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.begin
    Request(Unknown Source)
            at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(Unknow
    n Source)
            at org.omg.CORBA.portable.ObjectImpl._request(Unknown Source)
            at WorkflowFramework._ServiceStub.translationService(_ServiceStub.java:1
    8)
            at wF.ServantEnglishToGreek.translationService(ServantEnglishToGreek.jav
    a:294)
            at WorkflowFramework._ServiceImplBase._invoke(_ServiceImplBase.java:41)
            at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispa
    tchToServant(Unknown Source)
            at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispa
    tch(Unknown Source)
            at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest
    Request(Unknown Source)
            at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest
    (Unknown Source)
            at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(U
    nknown Source)
            at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.call
    back(Unknown Source)
            at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest
    (Unknown Source)
            at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatc
    h(Unknown Source)
            at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(
    Unknown Source)
            at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.
    run(Unknown Source)
    Caused by: java.net.ConnectException: Connection refused: connect
            at sun.nio.ch.Net.connect(Native Method)
            at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
            at java.nio.channels.SocketChannel.open(Unknown Source)
            at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket
    (Unknown Source)
            ... 19 more
    NEXT SERVER IS DOWN! org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 201
    completed: Noi added to my code the following catch
    try{
    //call next server
    nextServerRef.translationService(objRef, buffer);
    catch(org.omg.CORBA.COMM_FAILURE o){
    System.out.println("NEXT SERVER IS DOWN! "+o);
    }it is obvious that i haven't worked with exceptions a lot rather than some standard things.. which are the exact exceptions that i should catch and how??
    thx again!!
    Message was edited by:
    panosjava

  • I know that there are some clevers guys over this forum..I have a little

    question that doesn't refer to Java, But I was quite satisfied with your help that I will try my luck again.
    I am writing an application refering to AI field. I need to find a list of last names, computer products and companies as long as I can find for a initial data base to use it.
    Where can I find it?
    Thank you ,
    Amir

    If you just want a bunch of data for your app to run over, try census data. I know the U.S. govt has put some of its data on the web. If you want the data in a different language, hopefully a government of a country whose native language you want to write for, has done the same. It seems likely.

  • I have a 3rd generation ipod touch. I have attempted at least 3 times to update itunes to 10.10.54. It seemed to work, but then, i am unable to update my 3rd gen ipod touch. It says my version of 4.21. I know that there are higher versions. I have windows

    i ant update it. HELP

    Are you sure it is really a 3G iPod?  If it is 8 or 16 GB it is a 2G iPod. Apple only made 32 and 64 GB 3G iPods.  A 32 GB one can be either. To identify yours:
    Identifying iPod models
    Apple - Support - Check Your Service and Support Coverage

  • Text strings from VISA read don't match identical looking text constants - could it be double byte characters"

    Our RS232-enabled instrument sends ASCII strings to COM 1 and I read strings in. For example I get the string "TPM", or at least it looks like "TPM" if I display it. However, if I send that to the selector input of a Case structure, and create a case for "TPM", whether the two appear to match varies. Sometimes it matches, and measuring its length returns 3. Sometimes it measures 7 or 11 or 12 characters long, and it doesn't match. I can reproduce a match or a mismatch by my choice of the command that went to the instrument prior to the command that causes the TPM response, but have made no sense of this clue. I have run it through Trim Whitespace, with Both Ends (the default) explicitly selected. I have also turned the string into a byte array, autoindexed a For loop on that, and only passed the bytes if they don't equal 32, or if they don't equal 0, thinking spaces or nulls might be in there, but no better.
    The Trim Whitespace function's Help remarks that it does not remove "double byte characters". But I can't find anything else about "double byte characters". Could this be the problem? Are there functions that can tell whether there are "double byte characters", or convert into or out of them? By "double byte characters", do they just mean Unicode?
    Solved!
    Go to Solution.

    Cebailey,
    The double byte characters are generally used for characters specific to languages other than English.  If you display your message in  " '\' Codes Display"  in a string indicator do you see any other characters?   You could also use Hex Display to see count the number of bytes in the message.  You are probably getting messages with non-printable characters that might need to be trimmed before using your application.  If you want more information the '\' Codes Display, there's a detailed description found in the LabVIEW Help.  You can also find the same information on our website in the LabVIEW Help.  Backslash ('\') Codes Display
    Caleb WNational Instruments

  • Double Byte Characters for Japanese Kanji Language

    Hello All,
    How can you identify the Double Byte characters and how we can check whether they are double byte characters  or not.
    Can you please tell me the double byte characters from Japanese Kanji language for the characters.
    This is very urgent.I will reward you with points.
    Thanks,
    Karan

    *& Report  YTEST_LOGIC
    REPORT  teched_unicode_solution_1               .
    *** Exercise 1: Distinction between byte and character length
    *** after Unicode enabling
    parameter: param type c.
    PERFORM test1 USING param.
    *  FORM test1
    FORM test1 USING text TYPE c.
      DATA: len1 TYPE i,
            len2 TYPE i,
            off TYPE i.
    DESCRIBE FIELD text LENGTH len1 IN BYTE MODE.
    DESCRIBE FIELD text LENGTH len2 IN CHARACTER MODE.
    WRITE:/ LEN1, LEN2.
    ENDFORM.                                                    "test1
    Use the above code to find which characters are double bytes and which are not...
    The double byte characters will have double the length when they are in the byte mode..
    reward points for helpful answers
    Edited by: Rahul Kavuri on Mar 26, 2008 6:35 PM

  • Double byte characters in dataset

    Hi Gurus,
    I encounter an issue when writing data to dataset with fixed length.
    Company Code: US00
    Document Number: 1234567890
    Fiscal Year: 2014
    Line Item: 001 Short Text ( length 10 char): AF 16
    Line Item: 002 Short Text ( length 10 char): AF 16 
    Comment:X
    In Unix, it becomes like this:-
    US0012345678902014001AF16      X
    US0012345678902014001AF 16       X
    The X in second line item was not in correct fixed position and cause file being rejected by the receiver system.
    I have tried to calculate using the following syntax for AF 16  :
    1) strlen(bseg-sgtxt) = 7
    2) numofchar(bseg-sgtxt) = 6
    I would like to know if there is any idea to resolve the position of subsequent fields after "SGTXT" field if there is double byte characters found. I have tried to pad trailing space but it does not work.
    Expected result is where the X of two line items are located at same and fixed position:-
    US0012345678902014001AF16      X
    US0012345678902014001AF 16    X
    Thank you!

    /** returns true if the String s contains any "double-byte" characters */
    public boolean containsDoubleByte(String s) {
      for (int i=0; i<s.length(); i++) {
        if (isDoubleByte(s.charAt(i)) {
          return true;
      return false;
    /** returns true if the char c is a double-byte character */
    public boolean isJapanese(char c) {
      if (c >= '\u0100' && c<='\uffff') return true;
      return false;
    // simpler:  return c>'\u00ff';
    /** returns true if the String s contains any Japanese characters */
    public boolean containsJapanese(String s) {
      for (int i=0; i<s.length(); i++) {
        if (isJapanese(s.charAt(i)) {
          return true;
      return false;
    /** returns true if the char c is a Japanese character. */
    public boolean isJapanese(char c) {
      // katakana:
      if (c >= '\u30a0' && c<='\u30ff') return true;
      // hiragana
      if (c >= '\u3040' && c<='\u309f') return true;
      // CJK Unified Ideographs
      if (c >= '\u4e00' && c<='\u9fff') return true;
      // CJK symbols & punctuation
      if (c >= '\u3000' && c<='\u303f') return true;
      // KangXi (kanji)
      if (c >= '\u2f00' && c<='\u2fdf') return true;
      // KanBun
      if (c >= '\u3190' && c <='\u319f') return true;
      // CJK Unified Ideographs Extension A
      if (c >= '\u3400' && c <='\u4db5') return true;
      // CJK Compatibility Forms
      if (c >= '\ufe30' && c <='\ufe4f') return true;
      // CJK Compatibility
      if (c >= '\u3300' && c <='\u33ff') return true;
      // CJK Radicals Supplement
      if (c >= '\u2e80' && c <='\u2eff') return true;
      // other character..
      return false;
    /* NB CJK Unified Ideographs Extension B not supported with 16-bit unicode. Source: http://www.alanwood.net/unicode */
    }

  • Regular Expressions and Double Byte Characters ?

    Is it possible to use Java Regular Expressions to parse
    a file that will contain double byte characters ?
    For example, I want a regular expression to match the following line
    tag="double byte stuff" id="double byte stuff"

    The comments on the bytes/strings were helpful. Thanks.
    But I'm still confused as to what matching pattern could be used.
    For example a pattern like:
    [A-Za-z]
    I assume would not match any double byte characters.
    I also assume the following won't work either:
    [\\p{Alpah}]
    because it is posix - US-ASCII only.
    So how do you say "match the tag, then take any characters,
    double byte, ascii, whatever, then match the text tag - per the
    original example ?

  • I cannot get on to my Apple TV.  I know that they are now requiring a one time security code?  What is it How do I find it?

    I know that they are now requiring a one time security code.  How do I find it?  Does anyone know what it is?

    There is no such code required to use the Apple TV. A user can setup a passcode to be required for airplay, and Apple ID is required for use of the iTunes store (or any other subscriptions associated with it).

  • Started a similar string before.  When I select a recipient in Messages on my Macbook Pro the name shows up in red and says the recipient is no longer registered on iMessage.  I know that they are registered.  Is there a problem with Contacts?

    Started a similar string before.  When I select a recipient in Messages on my Macbook Pro the name shows up in red and says the recipient is no longer registered on iMessage.  I know that they are registered.  Is there a problem with Contacts possibly.  The previous help has been appreciated but the problem persists.

    Hi,
    Try iMessaging your own iPhone and see if your account is actually logged in.
    It can appear "enabled" and On line but sometimes it is not.
    Also try sending from your iPhone (number) to your Apple ID and see if it gets to the Mac.
    If it does not use the Sign Out button.
    Then shut down the Mac
    On restart add back the Apple ID to the iMessages account settings.
    I also just checked My wife's iPhone as she popped up red.
    It turned out her iPhone did not have Messages On.
    10:00 pm      Tuesday; January 28, 2014
      iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • I've downloaded some free games for my iphone4 but they are using my internet because they have ads. does anyone know if there are any games that don't have these ads and don't require internet AT ALL?and if i disable my internet connexion, does it help?

    i've downloaded some free games for my iphone4 but they are using my internet because they have ads. does anyone know if there are any games that don't have these ads and don't require internet AT ALL?and if i disable my internet connexion, does it help?

    Thank you. I put it in airplane mode like you suggested, but it looks to me like all the applications and ads are still running. Anyway, I'm just gonna play when I'm really really bored and use them as less as possible. Thank you again for your quick answer.

  • When I OCR two versions of the same document and then compare th documents in Acrobat Pro XI, I usually get the message that there are no changes to mark.  However, I know there a quite a few number of changes.  I raised this question more than a year ago

    When I OCR two versions of the same document and then compare the documents in Acrobat Pro XI, I usually get the message that there are no changes to mark.  However, I know there a quite a few number of changes.  I raised this question more than a year ago, and the response I received had to do with the quality of the OCR and the scans of the documents.  However, if I use Acrobat Pro XI to save the same documents in Word and then run a comparison in Word all of the changes are marked.  When a PDF is saved as a Word document in Acrobat Pro XI, is a different OCR module being used than the one used in Acrobat Pro XI for text recognition?

    OCR is only for recoginition of the image / picture of text provided by an scanner.
    Content typed into a Word file which is converted to a PDF is (in Word and in PDF) *not* an image  or picture of text - it is the digital text. So, no OCR involved.
    When the "digital" (renderable) text of a PDF's page content is exported to Word no OCR is involved.
    When a PDF's content is from the image output of a scanner and this is a picture of text then OCR comes into play.
    If this content is exported to Word before doing OCR then it is the image that is exported to the Word file.
    Once OCR is performed it is the OCR output that is exported.
    OCR output is (always will be) impacted by "the quality of the OCR and the scans of the documents". 
    Regardless "Compare" is based on a Word file output to PDF1 then edits to the Word file followed by an output to PDF2. You use Acrobat Pro to do a compare of PDF1 & PDF2.
    Paper 1 scanned to image 1 to image 1 in PDF1 that gets OCR 1 and
    Paper 2 scanned to image 2 to image 2 in PDF2 that gets OCR 2
    being processed with Acrobat Pro's Compare can certainly be done.
    But - well you've described what can be observed.
    Be well...

  • HT202731 How do i know that the fans are working on my iMac

    How do i know that the fans are working on my iMac

    the back of the monitor get hot and i can't hear any fans working

Maybe you are looking for