How to convert an UTF-8 String to Big5 String

Posted on 2004-11-07
Last Modified: 2008-02-26
Anyone knows how to convert an UTF-8 String to Big5 String?
Question by:yysasa
    LVL 92

    Accepted Solution

    It would be something like:

    String s = new String(utfbytes, "UTF-8");
    byte[] big5bytes = s.getBytes("Big5");

    Author Comment

    I tried the following code (strUTF8 contains UTF-8 characters):
    String s = new String(strUTF8.getBytes(), "UTF-8");
    byte[] big5bytes = s.getBytes("Big5");
    String strResult = new String(big5bytes, "Big5");

    but the strResult is not in Big5 format, why?
    LVL 86

    Expert Comment

    >>but the strResult is not in Big5 format, why?

    How are you determining this? For instance, if you're viewing the result in a Windows console, it won't support that encoding
    LVL 86

    Expert Comment

    Try to view it with a Swing component with its Font set to one that supports Big5 characters
    LVL 86

    Expert Comment

    >>but the strResult is not in Big5 format, why?

    Why did you post that comment after using the same code principle as in the comment you marked as the answer?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    Title # Comments Views Activity
    method argument as final 1 54
    Basics of Drool Rule Engine with few samples 2 31
    array220 challenge 8 30
    nestparen challenge 4 35
    If you have upgraded to Java2 update 10 on a Microsoft Windows client, you may have discovered that your Java application does not work as it did before.  For example, the colors of your Java2D graphic may be all wrong for no apparent reason. Aft…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now