Skip to content

obtain unicode character #325

@NanoJeoMichael

Description

@NanoJeoMichael

I'm working with a project need to parse unicode-characters, I got a xml-file almost like this:

<map>
    <unicode v="&#955;"/>
    <unicode v="a"/>
</map>

The value of attribute "v" in node "unicode" is an unicode character, (λ and a actually in above), the question is there's no function to access it (even if with ASCII-encoding, like 'a'), I try to code like:

const XMLElement* root = _doc.RootElement();
const XMLElement* e = root->FirstChildElement("unicode");
int v = 0; // or wchar_t
// add a function like QueryCharAttribute that can read unicode character ?
int err = e->QueryIntAttribute("v", &v);  // I got a error 'XML_WRONG_ATTRIBUTE'

and I tried this:

const char* s = e->Attribute("v");
wchar_t c = (wchar_t)s[0]; // I got a wrong value for '&#955'

I know there's a stupid way to solve this problem, just replace the unicode-character with it's code point, the xml would be like:

<map>
    <unicode v="955"/>
    <unicode v="96"/>
</map>

but is there any more efficient way to achieve my goal?
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions