www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Error: char 0x200b not allowed in identifier

reply zoujiaqing <zoujiaqing gmail.com> writes:
Error for code:
source/hunt/xml/Element.d(12,13): Error: char 0x200b not allowed 
in identifier
source/hunt/xml/Element.d(12,23): Error: character 0x200b is not 
a valid token
source/hunt/xml/Element.d(17,15): Error: char 0x200b not allowed 
in identifier
source/hunt/xml/Element.d(17,26): Error: character 0x200b is not 
a valid token
source/hunt/xml/Element.d(22,13): Error: char 0x200b not allowed 
in identifier
source/hunt/xml/Element.d(22,29): Error: character 0x200b is not 
a valid token
source/hunt/xml/Element.d(48,13): Error: char 0x200b not allowed 
in identifier
source/hunt/xml/Element.d(48,21): Error: character 0x200b is not 
a valid token
source/hunt/xml/Element.d(55,13): Error: char 0x200b not allowed 
in identifier
source/hunt/xml/Element.d(55,23): Error: character 0x200b is not 
a valid token
source/hunt/xml/Element.d(62,13): Error: char 0x200b not allowed 
in identifier
source/hunt/xml/Element.d(62,20): Error: character 0x200b is not 
a valid token


The Code file Element.d

```D
module hunt.xml.Element;

import hunt.xml.ElementType;

class Element
{
     this(string name)
     {
         this._name = name;
     }

     Element addElement​(string name)
     {
         return new Element(name);
     }

     Element[] getElements​()
     {
         return this._elements;
     }

     Element getParentELement​()
     {
         return this._parentElement;
     }

     Element removeAttribute(string key)
     {
         this._attributes.remove(key);

         return this;
     }

     Element addAttribute(string key, string value)
     {
         this._attributes[key] = value;

         return this;
     }

     Element setAttribute(string key, string value)
     {
         this._attributes[key] = value;

         return this;
     }

     Element addCDATA​(string cdata)
     {
         this._cdata = cdata;

         return this;
     }

     Element addComment​(string comment)
     {
         this._comments ~= comment;

         return this;
     }

     Element addText​(string text)
     {
         this._text = text;

         return this;
     }

     private
     {
         string _name;
         Element[] _elements;
         Element _parentElement;
         string[string] _attributes;
         string[] _comments;
         string _text;
         string _cdata;
     }
}
```
Jun 03 2019
parent reply ag0aep6g <anonymous example.com> writes:
On 03.06.19 15:37, zoujiaqing wrote:
 Error for code:
 source/hunt/xml/Element.d(12,13): Error: char 0x200b not allowed in 
 identifier
U+200B is: ZERO WIDTH SPACE. Somehow you got that invisible character into your code. You have to get rid of it. To do it manually, navigate to the locations the compiler gives you and find the spot where the cursor seems to get stuck for one key press. That's where a zero width space is. You can also open the file in a different non-Unicode encoding. The zero width spaces should stick out as non-ASCII symbols. Or you could write a program that goes over the file and filters the zero width spaces out. Or just re-write whole lines or the whole file by hand.
Jun 03 2019
parent zoujiaqing <zoujiaqing gmail.com> writes:
On Monday, 3 June 2019 at 14:41:18 UTC, ag0aep6g wrote:
 On 03.06.19 15:37, zoujiaqing wrote:
 Error for code:
 source/hunt/xml/Element.d(12,13): Error: char 0x200b not 
 allowed in identifier
U+200B is: ZERO WIDTH SPACE. Somehow you got that invisible character into your code. You have to get rid of it. To do it manually, navigate to the locations the compiler gives you and find the spot where the cursor seems to get stuck for one key press. That's where a zero width space is. You can also open the file in a different non-Unicode encoding. The zero width spaces should stick out as non-ASCII symbols. Or you could write a program that goes over the file and filters the zero width spaces out. Or just re-write whole lines or the whole file by hand.
Thanks :)
Jun 03 2019