473,769 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Se ttings)

'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.Sav e(ms)

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

'convert the bytes to string
Dim AE As New System.Text.ASC IIEncoding
strXML = AE.GetString(ar rBytes)

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 2245
* Cesar Ronchese wrote in microsoft.publi c.dotnet.xml:
'convert the bytes to string
Dim AE As New System.Text.ASC IIEncoding
strXML = AE.GetString(ar rBytes)

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.UTF 8Encoding 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****@hoehrma nn.de> escreveu na mensagem
news:40******** ********@news.b joern.hoehrmann .de...
* Cesar Ronchese wrote in microsoft.publi c.dotnet.xml:
'convert the bytes to string
Dim AE As New System.Text.ASC IIEncoding
strXML = AE.GetString(ar rBytes)

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.UTF 8Encoding 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
6596
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 test's.jpg - when I use an image tag to display the photo on my web page, no image displays. I tried to strip the slash out of the filename but the image still won't display on the web page - maybe I'm all goofed up here and don't understand what's...
6
2956
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 doesn't solve the problem. Error I get : XML Parsing Error: not well-formed Location: news.php?action=syndicate&format=rss2 Line Number 1, Column 102:<?xml version="1.0" encoding="ISO-8859-15"?><rss
19
5681
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 testscript I get an error message. # -*- coding: cp1252 -*-
3
7964
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 XSL Error: Could not parse c:\dxl\Abbink.xml document! XSL Error: SAX Exception Invalid UTF-8 code. (bytes: 0xffffffe9 0x20)
7
5002
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 replaced by what seems to be iso-8859-1 (which Flash doesn't understand, but that's another problem). Any help greatly appreciated. * Something like this...
6
6347
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 marks etc. When I enter the characters directly in SQL (using enterprise manager), they appear correctly in sql as well as in the browser when the asp page retrieves them. As soon as I hit save they get overwritten in sql incorrectly.
13
2213
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. Missing something? Thanks for help P. Cloup
5
6685
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
2187
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 StreamReader(sFichier) Dim sLine As String
0
9416
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,...
1
9981
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9850
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8862
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7396
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
5293
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
5436
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2810
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.