-3

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?

Harsh
  • 289

1 Answers1

1

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)

Homde
  • 11,134
  • 3
  • 41
  • 68
  • @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 06:57
  • Conducted at the time of Parsing
  • Cannot be changed during parser lifetime
  • Types: UTF-8 (PHP uses this type for internal Document representation; Bytes up to 21)
  • US-ASCII (Single byte)
  • ISO-8859-1(Single byte; Default)
  • – Harsh Jun 10 '11 at 07:04
  • What is it you're trying to do? – Homde Jun 10 '11 at 07:09
  • Actualy i want to know the Basic difference between these encodings? how they works? – Harsh Jun 10 '11 at 07: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 07:18
  • @mko:) Question edited bro – Harsh Jun 10 '11 at 07:20
  • UTF-8 works with "strange" characters (like UTF-16), most other encodings don't work with arbitrary "strange" characters. The only difference between UTF-8 and UTF-16 is the multiple of bits used. There are some characters that can be expressed in two bytes by UTF-16 and 3 by UTF-8. – Paul de Vrieze Jun 10 '11 at 11:49