How the encodings work? Which encodings can be used in XML?

To avoid errors

XML encoding while using PHP

I heard about

Character Encodings:
Source Encodings:
Target Encodings:

May i know what is the Difference between them?

closed as not a real question by user40980, Martijn Pieters, Kilian Foth, thorsten müller, gnat Apr 2 '13 at 10:56

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.


I think you can use any ISO combination in your xml declaration but the ones you usually see is UTF-8 and iso-8859-1 (for europe). Usually UTF-8 is a good choice unless you have lot's of strange characters

EDIT: I think you're confusing something like an XSLT transformation/parsing with XML instead of just the actual XML document.

An XML document has a character encoding. That is declared through the xml declaration. When you parse/transform XML you can many times separately define what the source encoding is and what the encoding the output should have (the target encoding)

  • @mko:)These are the types of source encoding i know that ... actualy i want to know the character encoding and target encoding ?nd also some other encoding if available – Harsh Jun 10 '11 at 6:57
  • 1. Conducted at the time of Parsing 2. Cannot be changed during parser lifetime 3. Types: UTF-8 (PHP uses this type for internal Document representation; Bytes up to 21) 4. US-ASCII (Single byte) 5. ISO-8859-1(Single byte; Default) – Harsh Jun 10 '11 at 7:04
  • What is it you're trying to do? – Homde Jun 10 '11 at 7:09
  • Actualy i want to know the Basic difference between these encodings? how they works? – Harsh Jun 10 '11 at 7:11
  • I don't think you ever really need to use anything different then UTF-8 and UTF-16 encoding. You only need to use UTF-16 for stuff like japanese, just make sure you save the file in the correct format as well as specify it in the declaration. Some parsers can use the Byte-order-mark to infer the encoding, but it's optional – Homde Jun 10 '11 at 7:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.