www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Named character entities

reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
What is the correct format for named character entities? According to
the online specs, I should be able to write:

	dchar ch = '&amp;';

But gdc-4.6.2 refuses to compile this; apparently it wants:

	dchar ch = '\&amp;';

Which is right??


T

-- 
People say I'm indecisive, but I'm not sure about that. -- YHL, CONLANG
Feb 13 2012
parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 02/13/2012 09:46 PM, H. S. Teoh wrote:
 What is the correct format for named character entities? According to
 the online specs, I should be able to write:

 	dchar ch = '&amp;';

 But gdc-4.6.2 refuses to compile this; apparently it wants:

 	dchar ch = '\&amp;';

 Which is right??


 T

The latter is right. The spec must be implying the \ character as all of the other special character syntaxes use it. One of the reasons is that character are specified the same way in strings. So "&amp;" is 5 characters as written. Again, a \ character is required to distinguish it as a single character literal. Ali
Feb 13 2012