How to Detect CJK in Java

104 21
    • 1). Download and install the Java Runtime Environment (JRE) to your system from Java.com. JRE will enable you to run the CJK Key application and load the Java applet automatically, which will prompt you for your CJK username and password. You must register if you are a first-time user of the KEY server.

    • 2). Enter your desired login name, password, real name and email address, and then hit "Submit" to complete your KEY applet registration. You must also download Microsoft CJK fonts to work with the Chinese, Japanese and Korean languages. The required Chinese fonts namely Pinyin with Tones, and Chinese character font, will be automatically provided by the KEY software.

    • 3). Input the following codes to automate the discovery of CJK characters in your Java strings.

      The code below will return "true" if the string S contains 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;

      }

      The following code will return "true" if the string C is a double-byte characters:

      public boolean isJapanese(char c) {

      if (c >= '\u0100' && c<='\uffff') return true;

      return false;

      // simpler: return c>'\u00ff';

      }

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.