Spadar Shut
Spadar Shut

Reputation: 15817

How to make js-generated xml file be in utf-8

I generate some xml in-browser and set it as data-uri for a link. When I click the link it is opened, but contents is recognized as ASCII and the text is garbled.

How do I make the content of the generated file be utf-8?

The xml starts with prolog <?xml version="1.0" encoding="utf-8" ?> but this doesn't help.

Upvotes: 2

Views: 890

Answers (1)

Spadar Shut
Spadar Shut

Reputation: 15817

So the answer is rather straightforward. I added the BOM mark \uFEFF to the beginning of the generated file and it worked fine. It looks tike this:

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

Upvotes: 2

Related Questions