473,385 Members | 1,588 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,385 software developers and data experts.

Saving xml with accentuated characters

Hello, All!

I'm working with accentuated characters in my XML files, and I have found
problems to load and save it.

First, for this case, I always have my XML in memory, and I load it via
LoadXML (please, ignore incorrect concatenations for this sample):
Dim cXml As New Xml.XmlDocument
Dim strXML as String

strXML = "<?xml version="1.0" encoding="ISO-8859-1"?>
<SETTINGS>
<COLUMNS>
<COLUMN INDEX="Code" WIDTH="0" Alias="Código">
</COLUMN>
</COLUMNS>
</SETTINGS>"

cXml.LoadXml(Settings)

'done, then I can do my changes
'.....

Then, when I need restore to memory that XML, the word "Código" becomes
"Csdigo". I save this manner:
Dim ms As New IO.MemoryStream
Dim arrBytes() As Byte
dim strXML as String

'saves my xml to a MemoryStream object
myXMLObject.Save(ms)

'read XML from MemoryStream
ms.Position = 0
ReDim arrBytes(ms.Length - 1)
ms.Read(arrBytes, 0, ms.Length)

'convert the bytes to string
Dim AE As New System.Text.ASCIIEncoding
strXML = AE.GetString(arrBytes)

Well, the word "Código" remains changed to "Csdigo". Its OK, if only in
files or strings, but, when I try reload to XML object again, the value
remains "Csdigo".
Have I made somethink wrong? Or there are some solution for it?

Thanks in advance!

Cesar
Nov 12 '05 #1
2 2232
* Cesar Ronchese wrote in microsoft.public.dotnet.xml:
'convert the bytes to string
Dim AE As New System.Text.ASCIIEncoding
strXML = AE.GetString(arrBytes)

Well, the word "Código" remains changed to "Csdigo". Its OK, if only in
files or strings, but, when I try reload to XML object again, the value
remains "Csdigo".


The problem here is that the ASCIIEncoding class does not support this
character, you should use UTF-8 or UTF-16 for your XML documents as
those encodings are most widely supported by XML processors, to do so
you could use the System.Text.UTF8Encoding class, but there are better
ways to store XML documents.
Nov 12 '05 #2
Cool! That works!

Was needed delete the encoding header, but was nice.

Thanks!

[]'s
Cesar
"Bjoern Hoehrmann" <bj****@hoehrmann.de> escreveu na mensagem
news:40****************@news.bjoern.hoehrmann.de.. .
* Cesar Ronchese wrote in microsoft.public.dotnet.xml:
'convert the bytes to string
Dim AE As New System.Text.ASCIIEncoding
strXML = AE.GetString(arrBytes)

Well, the word "Código" remains changed to "Csdigo". Its OK, if only in
files or strings, but, when I try reload to XML object again, the value
remains "Csdigo".


The problem here is that the ASCIIEncoding class does not support this
character, you should use UTF-8 or UTF-16 for your XML documents as
those encodings are most widely supported by XML processors, to do so
you could use the System.Text.UTF8Encoding class, but there are better
ways to store XML documents.
Nov 12 '05 #3

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

Similar topics

3
by: Ralph Freshour | last post by:
I have a PHP web app using MySQL - when I save a .jpg file named test's.jpg I see that the filename on the unix server is: test\'s.jpg - the filename I end up saving in my SQL table is named...
6
by: Jean-Marc Molina | last post by:
Hello, I'm trying to generate a RSS newsfeed using the DOM XML functions. However I can't find a way to use accentuated characters. I even tried to specify a character encoding set but it...
19
by: Svennglenn | last post by:
I'm working on a program that is supposed to save different information to text files. Because the program is in swedish i have to use unicode text for ÅÄÖ letters. When I run the following...
3
by: Ndeye | last post by:
hi everybody, I would like to parse an xml file containing some accentuated characters like è. This causes my java program to throw this error : file:/c:/dxl/Abbink.xml; Line 216; Column 26...
7
by: Philipp Lenssen | last post by:
How do I load and save a UTF-8 document in XML in ASP/VBS? Well, the loading* is not the problem actually -- the file is in UTF-8, and understood correctly -- but once saved, the UTF-8 is...
6
by: hilio | last post by:
I have an asp application that should allow the user to enter Unicode characters. The characters appear correctly in the browser. When saved in sql 2000 thought they are converted to question...
13
by: Pascal Cloup | last post by:
Hello, The methods Read() of the class StreamReader don't read the accentuated characters. When an accentuated character is present in a file, Read() skip it and read the following character....
5
by: Marcos Ribeiro | last post by:
Hi I'm trying to read a textfile using System.IO.StreamReader, but all accentuated characters are skiped. Why's that? There is any workaround? Thanks Marcos
2
by: jcdperf | last post by:
Hello, I have small problems while reading of text files containing accentuated characters. (like é è à ç ...). I use this basic code : Dim sr As StreamReader Try sr = New...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...

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.