473,666 Members | 2,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.AS CII.GetString(E ncoding.Convert (Encoding.GetEn coding("ISO-8859
-2"),Encoding.Ge tEncoding("wind ows-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 10314
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.AS CII.GetString(E ncoding.Convert (Encoding.GetEn coding("ISO-8859
-2"),Encoding.Ge tEncoding("wind ows-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.co m>
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
6753
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 cast the string properly to use it in the unmanaged code. I have tried to use the MarshalAs function in my DllImport statement but that didn't work. What i need is to take a string of numbers and convert it
4
9853
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 for a way to convert a string representing a long file path (whether or not it exists) to short (dos 8.3) form. This is what I have: private string GetShortPath(string longPath) { if (longPath.Length <= 8) { return longPath; } StringBuilder...
2
12184
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
7943
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 to work (the in and output remains the same): string x=toUTF8("=?GB2312?B?s8q5q8u+vq3A7aGissbO8bK/w8W1xNK7t+LQxQ==?=","GB2312");
1
2017
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 'encoded-word' as is explained in rfc2047), by using Convert.FromBase64String as Stefen kindly suggested (my post from yesterday).
3
4744
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 lpLocalName As String
8
2215
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 dwScope ; public Int32 dwType; public Int32 dwDisplayType;
5
9054
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? This is my function I am trying to get right: public static bool GetPrivateProfileSectionAsCS(string appName, string fileName, out string section)
4
2040
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 about VB :) I have chopped the code a bit so I hope it makes enough sense, what I am trying to do is load a remote registry in from a server , make some changes and then unload it.later. I have google'd quite a bit but I can only find C or VB6...
9
2857
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 dbcc_devicetype; DWORD dbcc_reserved; GUID dbcc_classguid;
0
8454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8362
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8878
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8785
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6200
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.