Cannot Switch to Unicode Error

I made an XML document "by hand" and wrote it to a file.

I then tried to read it with an XmlTextReader wrapping a FileStream. I
got an XmlException about "cannot switch to Unicode" or something.
Changing the from this:

<?xml version="1.0" encoding="utf-16"?>

to this

<?xml version="1.0" encoding="utf-8"?>

lets it run - why?


0
coconet (2)
7/21/2008 8:59:34 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
884 Views

Similar Articles

[PageSpeed] 5

"Co Co Net" <coconet@community.nospam> wrote in message 
news:lct984lu6m6qbplp62jqdgvqmtp11qkeqp@4ax.com...
>
> I made an XML document "by hand" and wrote it to a file.
>
> I then tried to read it with an XmlTextReader wrapping a FileStream. I
> got an XmlException about "cannot switch to Unicode" or something.
> Changing the from this:
>
> <?xml version="1.0" encoding="utf-16"?>
>
> to this
>
> <?xml version="1.0" encoding="utf-8"?>
>
> lets it run - why?
>
>
Most likely because your actual encoding clashes with the one stated in the 
version declaration..
If you want to fix it then give a minimal example of how you created your 
file and how you attempt to read it.

-- 

Joe Fawcett (MVP - XML)

http://joe.fawcett.name


0
7/22/2008 7:09:40 AM
Co Co Net wrote:
> I made an XML document "by hand" and wrote it to a file.
> 
> I then tried to read it with an XmlTextReader wrapping a FileStream. I
> got an XmlException about "cannot switch to Unicode" or something.
> Changing the from this:
> 
> <?xml version="1.0" encoding="utf-16"?>
> 
> to this
> 
> <?xml version="1.0" encoding="utf-8"?>
> 
> lets it run - why?

That sounds to me as if the XML document created "by hand" has a BOM 
indicating UTF-8 while you inserted an XML declaration declaring the 
encoding as UTF-16. So check how you saved the XML document, your editor 
might allow you to choose the encoding, if you want UTF-16 then make 
sure you save with that encoding.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
7/22/2008 11:25:26 AM
Reply:

Similar Artilces:

Development and Dexterity Error
Hi Everybody, My previouse computer died and I reinstalled everything to new one. GP (actually SBF) working fine without any problems. If I go to Dexterity and opening my development dic and go to Debug -> Test Mode I am getting an error: "A get/change first operation on table 'SY_Users_MSTR' (45)" Did I miss somehing? Thanks for your support. Can anybody provide any suggestions? Thanks :) "Vitaly Golden" <vitvov@dynamo-ny.com> wrote in message news:OMOc49xVKHA.4780@TK2MSFTNGP05.phx.gbl... > Hi Everybody, > > My previouse computer died...

Can you switch a documnet from a poster to a letter?
Once you created a poster can you resize it to a letter? I know that you can resize the paper, but the test remains poster size. I would create a .pdf file with that poster and then using Reader, print and scale it down to letter size. -- JoAnn Paules MVP Microsoft [Publisher] ~~~~~ How to ask a question http://support.microsoft.com/KB/555375 "o2binny" <o2binny@discussions.microsoft.com> wrote in message news:B7EC493A-5E9E-4485-A710-9C5748010316@microsoft.com... > Once you created a poster can you resize it to a letter? I know that you > can > resize th...

4.5.3 Error: too many recipients
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Email Client: imap Dear sirs, <br><br>I am receiving the following error: <br> 4.5.3 Error: too many recipients <br><br>When trying to sent an email with multiple recipients. Can you help me solve this problem? <br><br>Many thanks! <CabrioChallenge@officeformac.com> wrote: Hi, > Dear sirs, <br><br>I am receiving the following error: <br> 4.5.3 Error: > too many recipients <br><br>When trying to sent an email with multiple > recip...

Cannot display page error
Although I can connect to internet explorer (on my daughter's computer) it won't connect to any websites and just says "can't display page" and continues to try and connect but nothing happens. I have tested my connections and reset the internet explorer settings but am not getting very far. Would someone be able to advise me on what to do next (in very simple gargon) before I take it to the repair shop. Hoping someone can tell me what to do very soon. Complete novice Hi, First always please state your Windows version and IE version when posting ...

Application defined or object defined error
Hi All Here is a strange one I have a command button that envokes code "mnuExit" - this code does a bunch of different things and then closes the excel file. I have more code in the BeforeClose and Workbook_Deactivate events. Everything runs properly if there are no other Excel Files open - however - IF there are other excel files open once all the code has finished running I get a dialogue box that says: "Applicatiob-defined or object-defined error" there is no 1004 or anything else - and there is nothing in my code that is causing this error - I have s...

unicode application
hi, Priyanka here, this is a question related to VB. i want to make the VB application unicode based. i am not able to do it right now. if anybody knows please let me know about this. ...

error sychronizing headers
I keep getting an error Un-able to sychronize header for the in box on msn how can i fix it. this is a new problem prior to this i had no issue ...

Out of memory error
Hello all, I have a problem with Outlook 2003 on Win XP SP2, all service packs and Office updates. When I am trying to insert attachment to email message (new or reply to received) in RTF format, I receive an error "Out of memory or system resources. Close ...". 1,5 GB RAM in my notebook and no other applications running in the same time. 2GB of free space on my C: drive. When I switch the message format to Plain Text, I am able to insert an attachment. When I switch then back to RTF format, the error is displayed again. Any suggestions? Thanks. Vladimir Wojnar "msnew...

Find Worksheet Name without On Error Resume Next
Is there a way to ensure a worksheet is in a workbook without using the On Error Resume Next statement? I have the name of the worksheet, now I want to search the workbook for that sheet, how do I do that? -- Cheers, Ryan Hi Ryan It can be done like this: Dim IsThere As Boolean TargetSh = "Sheet1" For Each sh In ThisWorkbook.Sheets If sh.Name = TargetSh Then IsThere = True Exit For End If Next If IsThere Then MsgBox ("Is in the workbook") Else MsgBox ("Is not in the workbook") End If Regards, Per ...

Which control should I use to display Unicode characters?
Hi, there, I want to show Unicode characters, such as Chinese and Arabic. Which control should I use? Could you please give me a bit of example code? Thanks a lot. Gary You do not need specific control to display Unicode strings. Normally, you would use SetWindowText function to set the control text. If you look in winuser.h file this 'function' #defined as SetWindowTextA or SetWindowTextW (depending on the type of the build). If you want to use Unicode text regardless of build type, specify SetWindowTextW explicitly. Note that you need to have appropriate fonts installed to a...

VERIFY and TRACE, how to implement for debug/release, unicode-aware, no warnings at lvl 4
Hi group and apologize because this isn't a pure MFC-question. I have to finish a raw win32 app written in C++. I really miss the macros TRACE and VERIFY, which I tend to use when writing MFC programs. I googled for "win32 verify macro" and the very first hit is for a codeproject.com project with implementations to be used in a win32 program, however. The project contains a single header file, debug.h, but it doesn't compile without warnings (using warning level 4), doesn't seem to be unicode aware and doesn't compile at all in release mode. I was just wonderin...

W3SVC error
Hello everyone. I'm experiencing problems with Exchange 2000 SP3, I have an error in the Event log every five minutes on hours of high e-mail traffic that says: Event Type: Warning Event Source: W3SVC Event Category: None Event ID: 100 Date: 08/01/2004 Time: 09:51:49 User: N/A Computer: EXCHANGE2K Description: The server was unable to logon the Windows NT account 'administrator' due to the following error: Logon failure: unknown user name or bad password. The data is the error code. For additional information specific to this message please visit the Microsoft Online Suppor...

Fatal Error in Money 2003 Deluxe
About a week ago I first encountered a fatal error with Money 2003 Deluxe. After loading (apparently normally), if I click on the Portfolio icon in the Toolbar I get the following error twice after which Money shuts down: Error Msg Title Bar = Microsoft Visual C++ Runtime Library Msg = Runtime Error! D:\Program Files\Microsoft\Money\System\msmoney.exe The application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Has anyone else experienced this situation? Better yet, has anyon...

So why are YOU switching or not switching to Quicken?
I have seen many posts from users who have switched to Quicken and others who have no plans at all to switch to Quicken. I have used MS Money for 10 years and didn't activate Money Plus until this year so I will get updates until the bitter end in Jan 2011. I'm hoping this thread will be useful to discuss reason(s) to switch or not switch that people might not have thought of by themselves. So here the reasons I have come up with for why someone would or would not switch to Quicken. What's yours? Reasons for switching - Upset Microsoft discontinued Money - Your onlin...

OWA access is denied error
I am getting access is denied on my OWA. Right now, it looks like domain admins and the administrator can get in, but no one else. Just gives me ERROR: ACCESS IS DENIED I have went to the ExchWeb folder, and made it to where the authencated users have the correct permissions, also did this in IIS. Any other ideas? Dennis Try these: http://support.microsoft.com/kb/327843/en-us http://support.microsoft.com/kb/883380/en-us Nue "Dennis Burgess" <dmburgess@surdyk_e.com> wrote in message news:er$qjyWPGHA.916@TK2MSFTNGP10.phx.gbl... >I am getting access is denied on...

error 554
My emails wont send I get this error message: An unknown error has occurred. Subject 'Fw: Safety Manual section 3 Revision 2' Server Error: 554 Server Response: 554 Sorry, your non-local IP address (94.30.33.46) is not allowed to send email via me. Server: 'smtp.tiscali.co.uk' Windows Live Mail Error ID: 0x800CCC6F Protocol: SMTP Port: 25 Secure(SSL): No Tiscali UK only allow subscribers to send messages via their servers, if you have connected Internet via a Tiscali dial-up or Tiscali ADSL broadband connection. You are trying to send the message via the...

"#define UNICODE" problem
Hello, My MFC application compiles and runs OK. When I add: #ifndef UNICODE #define UNICODE #endif at the begining of STDAFX.H, the compiler goes mad and throws hundreds of error messages. What am I missing? TIA Yoav Ben-Yosef wrote: > Hello, > > My MFC application compiles and runs OK. When I add: > > #ifndef UNICODE > #define UNICODE > #endif > > at the begining of STDAFX.H, the compiler goes mad and throws hundreds of > error messages. What am I missing? > You're missing UNICODE support. You have to write code that works for both UNICODE an...

Run-time error -2147217900 (80040e14)
I'm running a third-party database app that provides an xla file for Excel for querying the back-end database (in MSSQL). We're upgrading our application servers and moving from Excel 2003 Pro (32-bit) under Windows Server 2003 64-bit to Excel 2010 Pro Plus (32- bit) on Windows Server 2008 R2 (64-bit.) Now, however, I'm running into the above error when trying to run a query from Excel. Strangely it works perfectly when I run this from my Windows 7 (64-bit) PC with Excel 2010 Pro Plus (32-bit). So I'm ruling out a syntax error that 2010 is nit-picking over that 2003 didn'...

Have switched to Apple Mail!
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: Exchange Too many problems with syncing, missing email, etc. etc. <br><br>I've now switched to Apple Mail and it works WAY better! How easy was it to transfer all your old email and folders? 2008 was a big disappointment for me because I only got 1 minor feature I was waiting for (thesaurus access) and the HTML editing that nearly everyone asked for since 2004 came out was still missing. In fact, like Office 2007 on the PC, the user interface (in the other office applicat...

.net messenger servises 80070005 error
I have tried everything like no joke everything i was thinkin about a MS DOS but i dont have the disks for that any ideas? -- Whitetiger89 ...

on Writexml error
(Type your message here) Hi all, I have a XML file as a datasource. I read that file using dataset.readxml.Then in that dataset I make some changes. Now I want to write that changed dataset by overwriting the file that was created initially. I someone please tell me how to do it. -------------------------------- From: ratnesh gupta ----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/) <Id>sCyOfoucUUyYsxAsNxg9AA==</Id> ...

Error Message
Error Number: 0x800C0133 When I want to download the emails, the error message says as "An unknown error has occurred.Protocol: POP3, Port: 110, Secure(SSL): No, Error Number: 0x800C0133" What does this mean and how to correct this error? This issue usually indicates that you need to scan your pst-file for errors with scanpst.exe; http://www.msoutlook.info/question/77 Also, do you have a virus scanner installed which integrates itself with Outlook? Uninstall this integration part of your virus scanner and try again; you'd still be sufficiently protected ...

/3gb switch
On 2 brand new Exchange 2003/Windows 2003 installs, I have modified the boot.ini file to include the /3GB /USERVA=3030 Exactly as instructed on the knowledgebase. However, I still recieve the memory settings warning whenever the servers boot up. Any ideas? The following KB article should guide you through some other settings that can be modified to optimize memory usage. http://support.microsoft.com/default.aspx?kbid=815372&product=exch2003 -- Ben Winzenz Exchange MVP "Jorge Azcuy" <Jorge Azcuy@discussions.microsoft.com> wrote in message news:25EA3E6F-C66F-478A-...

OE Error
Why wont Outlook Express allow me to open certain attachments,even though i know they are safe? PLz help. Thank you nic Tools->options->security tab. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the SWEN virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, Nicole asked: | Why wont Outlook Express allow me to open certain | attachments,even though i know they are safe? | | PLz help. | | Thank you | | nic ...

error after runing MS update last weel 10/13/2005
After getting update from microsoft I got error when trying sending email from MS excel program as attachment, with this error: general mail failure. quit microsoft exel, restart the mail system, and try again. ...