473,503 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

encoding always gets defaultencoder

Hi,

I have a very common problem. I try to change my encoding from
defaultencoding (UTF-16) to iso-8859-15.
My source:

Encoding encoder = Encoding.GetEncoding("iso-8859-15");
log.logDebug("Encoding is " + encoder.GetEncoder());
byte[] byteArray = new byte[buffer.Length];
byteArray = encoder.GetBytes(buffer);

the logging output:

Encoding is System.Text.Encoding+DefaultEncoder

Does anybody has an idea. I would appreciate it.

Marco

Nov 16 '05 #1
6 1492
Hi Marco,

I'm not too familiar with the Encoder class, but I believe it is created
based on the number of bytes needed to define a character in a certain
Encoding, so any of the 8-bit encodings like "ISO-8859-15" would create an
Encoder of default type.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #2
Is there another way to determin the encoding, so that iso-8859-15 is token?

"Morten Wennevik" wrote:
Hi Marco,

I'm not too familiar with the Encoder class, but I believe it is created
based on the number of bytes needed to define a character in a certain
Encoding, so any of the 8-bit encodings like "ISO-8859-15" would create an
Encoder of default type.

--
Happy Coding!
Morten Wennevik [C# MVP]

Nov 17 '05 #3
Marco,

System.Text.Encoding.GetEncoding(437).GetBytes()

I don't know what thable that 8859 is I thought 1252

Cor
Nov 17 '05 #4
Hi Cor,

tried this already. But it doesn't matter which parameter I pass the method
GetEncoding(), I always become the Default- Encoder.

Some parametervalues I used: "ISO-8859-15", 1252, 437

Marc

"Cor Ligthert" wrote:
Marco,

System.Text.Encoding.GetEncoding(437).GetBytes()

I don't know what thable that 8859 is I thought 1252

Cor

Nov 17 '05 #5
What are you trying to accomplish?
On Tue, 22 Mar 2005 05:11:08 -0800, Marco
<Ma***@discussions.microsoft.com> wrote:
Hi Cor,

tried this already. But it doesn't matter which parameter I pass the
method
GetEncoding(), I always become the Default- Encoder.

Some parametervalues I used: "ISO-8859-15", 1252, 437

Marc

"Cor Ligthert" wrote:
Marco,

System.Text.Encoding.GetEncoding(437).GetBytes()

I don't know what thable that 8859 is I thought 1252

Cor


--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #6
Marco <Ma***@discussions.microsoft.com> wrote:
I have a very common problem. I try to change my encoding from
defaultencoding (UTF-16) to iso-8859-15.
My source:

Encoding encoder = Encoding.GetEncoding("iso-8859-15");
log.logDebug("Encoding is " + encoder.GetEncoder());
byte[] byteArray = new byte[buffer.Length];
byteArray = encoder.GetBytes(buffer);

the logging output:

Encoding is System.Text.Encoding+DefaultEncoder

Does anybody has an idea. I would appreciate it.


That's giving the right encoder - it's just implemented by a class
called DefaultEncoder nested inside Encoding.

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

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

Similar topics

10
5510
by: lawrence | last post by:
Validator chokes on my pages now because I started sending an character encoding header of UTF-8 but the page is full of non UTF-8 characters. Anyway quick way to convert them? ...
5
6475
by: Edward K. Ream | last post by:
Am I reading pep 277 correctly? On Windows NT/XP, should filenames always be converted to Unicode using the mbcs encoding? For example, myFile = unicode(__file__, "mbcs", "strict") This...
1
1347
by: Paulo da Silva | last post by:
Hi. I am using unicode encode method to write some accented chars to files (%s). Do I need to use the method "encode" always? Isn't there a general way to declare the encoding for the whole...
37
10115
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
2
14835
by: xmlguy | last post by:
This is part of the application that reads XML from file (that has UTF-8) into an XmlTextReader XmlTextReader myXmlReader = new XmlTextReader(args); It then instantiates an object/class...
6
18719
by: jmgonet | last post by:
Hello everybody, I'm having troubles loading a Xml string encoded in UTF-8. If I try this code: ------------------------------ XmlDocument doc=new XmlDocument(); String s="<?xml...
8
1861
by: pagates | last post by:
Hello, I am playing a little with Encoding, and I have what is possibly (forgive me) a newbie-type question. I have a function that takes a string and a codepage (based upon the basic MSDN...
9
23688
by: Mark | last post by:
I've run a few simple tests looking at how query string encoding/decoding gets handled in asp.net, and it seems like the situation is even messier than it was in asp... Can't say I think much of the...
0
1278
by: Simon Niederberger | last post by:
Hi all I'm having some trouble with UTF8 / ISO-8859-1 encoding using a Webservice based on PEAR::SOAP_Server. The client essentially sends an XML file as data (i.e. XML-data wrapped in SOAP-XML...
0
7198
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,...
0
7271
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,...
0
7319
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...
1
6979
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
7449
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...
1
4998
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
4666
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...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.