Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support encodings #258

Open
LucCappellaro opened this issue Apr 13, 2023 · 0 comments
Open

Support encodings #258

LucCappellaro opened this issue Apr 13, 2023 · 0 comments

Comments

@LucCappellaro
Copy link

The Builder-Options allow to specify a custom encoding.
However this has no effect, except changing the xml declaration.
According to the XML spec:

... it is a fatal error for an entity including an encoding declaration
to be presented to the XML processor
in an encoding other than that named in the declaration, ...

Browsers and NodeJS support multiple encodings. It would be great if xmlbuilder-js would support this too.

To be clear, changing the encoding can have an impact on the XML representation.
Unsupported character need to be escaped with numeric character references.

Example in UTF-8:

<?xml version="1.0" encoding="UTF-8"?>
<test>
  <english>Hello World</english>
  <portuguese>Olá Mundo</portuguese>
  <czech>Ahoj světe</czech>
  <chinese>你好,世界</chinese>
</test>

Same example in ISO-8859-1:

<?xml version="1.0" encoding="ISO-8859-1"?>
<test>
  <english>Hello World</english>
  <portuguese>Olá Mundo</portuguese>
  <czech>Ahoj sv&#283;te</czech>
  <chinese>&#20320;&#22909;&#65292;&#19990;&#30028;</chinese>
</test>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant