Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading swedish characters thro DataInputStream  RSS feed

 
Gayathri Nagarajan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My project basically deals with 3 platforms. One is the UI with Windows, the middle end with linux box and a server which is on VxWorks.
i save a data with swedish character in the UI. We use Solid database to store the data. So i have introduced a CAST with WVARCHAR which can accept and store these characters. The data goes to the server which runs on VxWOrks , stores the data properly. But when i try to get the data back, it does'nt come properly. eg: if i give ��� , when i try to retrieve from the server, i get as �

� �



which does'nt help me further. i tried using a Buffered Reader to read the data , but none of them work . Please help me with the problem. What needs to be done? I assumed that the data we get from the server supports 0-255 range and since java can support only (-127 to +127) , we get the problem .But still reading with Readers doesnt work. I have tried introducing DataInputStream,charset decoders .
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what "WVARCHAR" is, but you need to make sure that the encoding being used is the same everywhere, e.g. Unicode in the shape of UTF-8. Note that this is a setting that usually needs to be made when the database is created.

If the encoding being used for some reason can't be the same everywhere, you need to convert between encodings in appropriate places. Never rely on the platform default encoding - always be specific which one should be used.

I assumed that the data we get from the server supports 0-255 range and since java can support only (-127 to +127)

Rather than assuming anything, make sure what kind of encoding the DB uses. Java can support the full range of Unicode, so the remark about +/-127 doesn't make sense in this context.
[ February 27, 2008: Message edited by: Ulf Dittmer ]
 
Gayathri Nagarajan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your reply. I'm using ISO-8859-1 as the encoding throughout.I'm not aware of how to set the encoding for the SOLID database.
Please help me on that. I have one more doubt too . I saved a xml file with encoding as UTF-8 and opened thro explorer. I was able to see the swedish characters. The same file i transferred to my linux box and opened by doing a cat. The swedish characters were not displayed properly. Please let me know the reason for the same. DOes it mean that my linux box is not configured to support multi languages?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using ISO-8859-1 as the encoding throughout.I'm not aware of how to set the encoding for the SOLID database.

I don't know what a SOLID database is; check with your DB admin that the encoding it uses is ISO-8859-1 as well.

I saved a xml file with encoding as UTF-8 and opened thro explorer. I was able to see the swedish characters. The same file i transferred to my linux box and opened by doing a cat. The swedish characters were not displayed properly.

The console on which cat displays its output may not be able to display Unicode. Open the file with a program that knows how to do that (e.g. OpenOffice). I'm sure there are text editors that can do it as well.
[ February 29, 2008: Message edited by: Ulf Dittmer ]
 
Gayathri Nagarajan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your suggestion. i tried to open the file through putty by changing the character set and it works
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!