🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Unicode Conversion - Help

#8221
From: Harry Whitehouse
Date: Fri, 13 Apr 2001 19:23
60 lines
3512 bytes
Here's a bit more on what I'm trying to do.   I've created a little ISAPI
module called ISAPIUNICODE.DLL on the server noted below (you can hit this
if you want!).  When you  hit it with any type of data (RequestHEX), it will
simply return a string of 256 bytes starting from x00 through xFF.  I
created this little test DLL to isolate the conversion problem I'm having.

         String VPOURL2="http://38.168.115.174/isapi/isapiunicode.dll";
         System.out.println(VPOURL2.toString());

         URL url = new URL(VPOURL2);
         URLConnection uc = url.openConnection();
         uc.setDoOutput(true);
         uc.setDoInput(true);
         uc.setUseCaches (false);
         uc.setRequestProperty("Content-Type", "application/octet-stream");
         DataOutputStream dos = new DataOutputStream(uc.getOutputStream());
         // Send the data -- this seems to pass all of the hex information
with any Unicode issues!
         dos.write(RequestHEX);
         dos.flush();
         dos.close();

Now I try to capture these 256 bytes.  I've tried a number of approaches
(using bytes, ints, etc) , but let's take a very simple one:

         InputStreamReader MyInputStream = new
InputStreamReader(uc.getInputStream());
         BufferedReader drate= new BufferedReader(MyInputStream);
         StringBuffer response = new StringBuffer("");
         rateline = drate.readLine();   // production problem -- readline
will terminate when it encounters a \n or \r!!
         while(rateline != null) {
             response.append(rateline);
             rateline = drate.readLine();
         }
         System.out.println(response.toString());


If I inspect response in the debugger, I see:

             response[0] = \u0000;
             response[1]=  \u0001;
            ..................
             response[123]= \u007F;
             response[124]=\u20AC;   // should be byte x80
             response[125]=\uFFFD;
             .........
             response[155]=\u0178';  // should be byte x9F
             response[156]=\u00A0;
             response[157]=\u00A1;
             ...
             response[255]=\u00FF;


So my incoming message bytes are being "distorted" with the unicode
conversion in the range of \x80 through \x9F.

How can I avoid this?  I need to convert these simple byte values to
numbers, and when a number just happened to include a byte in the
aforementioned range, I can't evaluate the number correctly!
Technical Details
Message-ID: <3ad7522f$1_1@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3ad4f06c$2_2@dnews> <MPG.154086682953719398a11d@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,eba31f969c5fae3c
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-04-13 12:44:26 PST
From: "Harry Whitehouse" <harry@envmgr.com>
Newsgroups: borland.public.jbuilder.java.language
References: <3ad4f06c$2_2@dnews> <MPG.154086682953719398a11d@forums.borland.com>
Subject: Re: Unicode Conversion - Help
Date: Fri, 13 Apr 2001 12:23:34 -0700
Lines: 68
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 38.168.115.135
Message-ID: <3ad7522f$1_1@dnews>
X-Trace: dnews 987189807 38.168.115.135 (13 Apr 2001 12:23:27 -0700)
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews