Article View: borland.public.jbuilder.java.language
Article #8644Re: looking for converter from standard Ascii to UTF8 format before create XML file
From: Johan Forsberg
Date: Mon, 05 Mar 2001 10:36
Date: Mon, 05 Mar 2001 10:36
29 lines
2083 bytes
2083 bytes
"badaie" <badaie@hotmail.com> skrev i meddelandet news:3aa35337$1_2@dnews... > > Hi All, > > I'm looking for an existing class or method able to modify a bufferString (comming from a database) with caracters like '����...' on a valid UTF8 format before create an xml File. Standard ASCII can't diplay characters like '����'... I assume you mean ISO 8859-1 (Windows,Linux,...) Anyway, since you already have a StringBuffer (?), the decoding from ISO has already taken place. Remember, all chars in Java (and classes that are lists of chars like String and StringBuffer) use Unicode UTF-16 to represent the chars. What's left is to encode as UTF8. OutputStream xmlOS=....; OutputStreamWriter xmlWriter=new OutputStreamWriter(os, "UTF-8"); xmlWriter.write(myString); Wrap xmlWriter in a PrintWriter if you want println(). Oh, and the call to convert a byte[] b to a String using for instance ISO 8859-1 is new String(b, "ISO-8859-1");
Technical Details
Message-ID:
<97vq7c$j812@bornews.inprise.com>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-xfer.nuri.net!enews.sgi.com!newshub2.rdc1.sfba.home.com!news.home.com!news-out.usenetserver.com!news-out-sjo.usenetserver.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!not-for-mailReferences:
<3aa35337$1_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,CP1252 X-Google-Thread: f74b3,35f1abce27355053 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-03-05 02:48:03 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-xfer.nuri.net!enews.sgi.com!newshub2.rdc1.sfba.home.com!news.home.com!news-out.usenetserver.com!news-out-sjo.usenetserver.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!not-for-mail From: "Johan Forsberg" <jfo@SPAMfinansforbundet.SPAMse> Newsgroups: borland.public.jbuilder.java.language Subject: Re: looking for converter from standard Ascii to UTF8 format before create XML file Date: Mon, 5 Mar 2001 11:36:19 +0100 Organization: Another Netscape Collabra Server User Lines: 30 Message-ID: <97vq7c$j812@bornews.inprise.com> References: <3aa35337$1_2@dnews> NNTP-Posting-Host: 193.12.51.113 Mime-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8bit 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