Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we always use xml version="1.0" and encoding="utf-8" in XML of Android?

I have a basically question about XML in Android. This line that is shown at the top of XML files <?xml version="1.0" encoding="utf-8"?> is changeable? I mean we can use for example utf-16 or another version of xml in our codes?

like image 455
MMG Avatar asked Oct 18 '25 12:10

MMG


1 Answers

No, there are instances in which the XML encoding and version could or should be different. Different versions of XML are, as expected, different, while different encoding will allow for characters not included in traditional "utf-8" encoding.

EDIT: Re: "Thanks for your answer, I want example for it" & "OK, when do we use utf-16? Is there any code with another version of xml?"

UTF-16 doesn't have much use, as I understand; it is mostly just an old system used for backwards compatibility or for a code that maximizes efficiency with 16-bit over 8-bit. You might use UTF-32 as (from Wikipedia) "the Unicode code points are directly indexed."

From another post on StackOverflow regarding XML versions, "You would only need to use version 1.1 if you are using certain non-ASCII characters in identifiers, EBCDIC line ending characters, or control characters (character codes 1 - 31)."

like image 131
Randall Arms Avatar answered Oct 20 '25 02:10

Randall Arms



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!