473,413 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

How to convert string charset?

Hello!

I need to conver string (sql statement) from one Polish charset standard
(ISO-8859-2) to another (Win-1250). Using help I managed to create line like
this one:
sql=Encoding.ASCII.GetString(Encoding.Convert(Enco ding.GetEncoding("ISO-8859
-2"),Encoding.GetEncoding("windows-1250"),Encoding.ASCII.GetBytes(sql)));
But it doesn't work. I know that ASCII isn't right here because it's 7 bit
representation and special characters are in the "second part" of the
charset.

How should I do it?

Regards
Leon
Nov 16 '05 #1
1 10267
Mirosław Iwanowski <mi****************@messer.pl> wrote:
I need to conver string (sql statement) from one Polish charset standard
(ISO-8859-2) to another (Win-1250). Using help I managed to create line like
this one:
sql=Encoding.ASCII.GetString(Encoding.Convert(Enco ding.GetEncoding("ISO-8859
-2"),Encoding.GetEncoding("windows-1250"),Encoding.ASCII.GetBytes(sql)));
But it doesn't work. I know that ASCII isn't right here because it's 7 bit
representation and special characters are in the "second part" of the
charset.

How should I do it?


Strings themselves are always in unicode, whatever their origin. Unless
you're really dealing with the byte arrays, you shouldn't need to do
any conversion. It sounds like you may have received bad data to start
with, if you're having problems.

See http://www.pobox.com/~skeet/csharp/unicode.html for more
information.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jim | last post by:
I have to access a third party api to work with their hardware. Everything was going great UNTIL I ran into the problem of C# char being 16 bits and the C char being 8 bits. I cannot seem to...
4
by: James Geurts | last post by:
Hi all, I'm trying to convert a string representing a path to Dos 8.3 notation. The code that I have works fine if the path exists, but it will not work if the path does not exist. I am looking...
2
by: Mel WEaver | last post by:
Hello, I have the following delphi structure for a binary file. I'm looking for idea how to read this file. Mel type TMenuDataStruct = packed record exename : string;
4
by: Albert Jan | last post by:
Hi, I have text from mime email messages with different encoding that I want to convert to utf-8, but I'm relatively new on encoding problems. I use the following code, but this doesn't seem...
1
by: Albert Jan | last post by:
Hi, in my quest to properly display email messages I have overcome the problem of decoding strings like "=?GB2312?B?s8q5q8u+vq3A7aGissbO8bK/w8W1xNK7t+LQxQ==?=" (which appears to be an...
3
by: Gee | last post by:
Hi Can anyone help me convert this to C# please? Structure NETRESOURCE Public dwScope As Int32 Public dwType As Int32 Public dwDisplayType As Int32 Public dwUsage As Int32 Public...
8
by: Gee | last post by:
I get the above error with this code and I can't figure out why? Any ideas please? See code below - the actual error is included in the code: public struct NETRESOURCE { public Int32...
5
by: Marc | last post by:
Hello dear, I have a string and every second char is a \0. Can I somehow convert it to a normal string. Or may-be in the underlying code I am doing something wrong, choose the wrong C# type? ...
4
by: jg007 | last post by:
Hi, I have some code that somebody has vritten in C and although I have got it to roughly work it is hard going and I can't get it to do exactly what I want as I know even less about c than I do...
9
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, i am a little stuck here, how do i convert this from C Structure to an structure in C# that can be marshalled: typedef struct _DEV_BROADCAST_DEVICEINTERFACE { DWORD dbcc_size; DWORD...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.