🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7827

Re: Retrieving Chinese characters from Properties file

#7827
From: Jonathan Chen
Date: Thu, 17 May 2001 04:04
80 lines
3844 bytes
Hi, I am a newbie in java. I saw the folowed message, so i think this
pattern of source maybe helpful.
    try {
      sReceiveStr = new String(sReceiveStr.getBytes("GBK"),"ISO8859-1");
    } catch (Exception e) {
      sReceiveStr = e.getMessage();
    }

Jonathan C
"Alex" <zzling@21cn.com> wrote in message
news:47d6gtklno6cscin0pi7a8k3ajqn4tu8tt@4ax.com...
> hi cxing, i write a test by your sample code.  but i can't show
> chinese char.
>
> so now. i have some question:
> 1. my properties must be unicode file? or UTF8 file?
> 2.how to show chinese in my java app?
>
> alex
> Email: alex@263.net.cn
>
> On Wed, 11 Oct 2000 16:49:33 -0700, "cxing" <cxing@inprise.com> wrote:
>
> >You can write a simple conversion program to escape extended characters.
> >Something like this
> >  static final char[] hexes =
> >{'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'} ;
> >  String escapeString(String src) {
> >    char[] chars = src.toCharArray() ;
> >    char[] ud = new char[4] ;
> >    StringBuffer buff = new StringBuffer();
> >    for(int i=0;i<chars.length;i++) {
> >      if(chars[i] > 0x7f) {
> >        ud[0] = hexes[chars[i] & 0x000f] ;
> >        ud[1] = hexes[(chars[i] & 0x00f0) >> 4] ;
> >        ud[2] = hexes[(chars[i] & 0x0f00) >> 8] ;
> >        ud[3] = hexes[(chars[i] & 0xf000) >> 12] ;
> >        buff.append("\\U") ;
> >        buff.append(ud[3]) ;
> >        buff.append(ud[2]) ;
> >        buff.append(ud[1]) ;
> >        buff.append(ud[0]) ;
> >      }else {
> >        buff.append(chars[i]) ;
> >      }
> >    }
> >    return buff.toString() ;
> >  }
> >
> >Chris Xing
> >International R&D Engineer
> >JBuilder Team
> >Borland/Inprise
> >
> >"Sheilagh Bill" <SheilaghB@impro.co.za> wrote in message
> >news:39E31095.A34AC6BF@impro.co.za...
> >> Hi
> >>
> >> My application allows dynamic translation of resource strings from the
> >> screen, stores them to a resource properties file.  A user can then
> >> select a locale (hence the relevant properties file) for display.  This
> >> works correctly for Latin 1 encoding.
> >>
> >> In a Chinese Windows O/S the characters can be captured and written to
> >> the file and appear correct when viewed with Notepad or Wordpad.
> >> However when the getString method of the ResourceBundle is used to
> >> retrieve the resource strings the characters are changed.  Looking at
> >> Borlands sample multi-lingual program I notice that all characters
above
> >> ASCII 127 are entered as a unicode escape sequence. This reads back
> >> correctly but is this required? I have tried writing the file with
> >> JavaOutputStreamWriter and EncodedOutputStream but the Chinese
> >> characters are still not written out as unicode escape sequences.
> >>
> >> Please can anyone help, I don't know where to look anymore.
> >> Thanks
> >>
> >> Sheilagh Bill
> >
>
Technical Details
Message-ID: <3b034df3_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.sj.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!130.133.1.3!fu-berlin.de!news.boerde.de!dnews
References: <39E31095.A34AC6BF@impro.co.za> <8s2tgl$mer17@bornews.borland.com> <47d6gtklno6cscin0pi7a8k3ajqn4tu8tt@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,b0148acea17952b4
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-05-16 21:43:49 PST
From: "Jonathan Chen" <iwdm@21cn.com>
Newsgroups: borland.public.jbuilder.java.language
References: <39E31095.A34AC6BF@impro.co.za> <8s2tgl$mer17@bornews.borland.com> <47d6gtklno6cscin0pi7a8k3ajqn4tu8tt@4ax.com>
Subject: Re: Retrieving Chinese characters from Properties file
Date: Thu, 17 May 2001 12:04:54 +0800
Lines: 82
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6700
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
NNTP-Posting-Host: 202.104.49.168
Message-ID: <3b034df3_1@dnews>
X-Trace: dnews 990072307 202.104.49.168 (16 May 2001 21:05:07 -0700)
Path: arc1-ca.pugleaf.net!archiver1.sj.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!130.133.1.3!fu-berlin.de!news.boerde.de!dnews