You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Damien Damien <da...@hotmail.com> on 2003/07/29 15:43:31 UTC
UTF8 problems
I know this isn't the user mail list... But I couldn't find one... And I
have a problem. So PLEASE help me :_(
I'm using xerces to read a config file to get multilanguage support:
It looks like this...
<?xml version="1.0" encoding="UTF-8"?>
<Language>
<Phrase key="OutOfMemory">Slut pĺ minne</Phrase>
<Phrase key="FileNotFound">Filen kunde inte hittas</Phrase>
</Language>
Now, I'm new to both xerces and unicode. I wonder how do I get the string
that corresponds to a key and put it in a string or something as UTF-8?
I tried somthing like this...
void Unicode::ReadStrings(DOMNodeList* pNodes)
{
DOMCharacterData* child;
DOMElement* attribute;
int node_list_length = pNodes->getLength();
for (int i = 0; i < node_list_length; ++i)
{
attribute = dynamic_cast<DOMElement*>(pNodes->item(i));
child =
dynamic_cast<DOMCharacterData*>(pNodes->item(i)->getFirstChild());
cout << "Length: " << child->getLength() << endl;
// if p_element is NULL the node is probably a comment
if (child != NULL)
{
string text_string = XMLString::transcode(child->getData());
AddString(key, text_string);
.............
child->GetData() returns an XMLCh* containing for example 'Slut pĺ minne'.'
But when I tried to use that string in SDL_ttf to print a UTF8 string on the
screen it only works as long as the string contains ASCII charaters... When
I put an ĺ, ä or ö in it doesn't work...
Also, when I try to print text_string with cout it doesn't work when I try
to use special chatares...
Thanks in advance... And sorry for taking up your time
Daniel
_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: UTF8 problems
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
I don't know what SDL_ttf is but here goes a short explanation of
what is going on. If you are using the DOMWriter to write out UTF-8 then
in order to see all the characters you will need to open it in a
editor/browser that understands UTF-8. XMLCh is UTF-16 so you will need to
transcode it before you can see it (I don't know if SDL_ttf will do this
for you). As for the matter of the transcode, it will transcode to your
local code page. Does your local code page support these special
characters?
Gareth
On Tue, 29 Jul 2003, Damien Damien wrote:
> I know this isn't the user mail list... But I couldn't find one... And I
> have a problem. So PLEASE help me :_(
>
> I'm using xerces to read a config file to get multilanguage support:
> It looks like this...
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Language>
> <Phrase key="OutOfMemory">Slut på minne</Phrase>
> <Phrase key="FileNotFound">Filen kunde inte hittas</Phrase>
> </Language>
>
> Now, I'm new to both xerces and unicode. I wonder how do I get the string
> that corresponds to a key and put it in a string or something as UTF-8?
> I tried somthing like this...
>
> void Unicode::ReadStrings(DOMNodeList* pNodes)
> {
> DOMCharacterData* child;
> DOMElement* attribute;
>
> int node_list_length = pNodes->getLength();
> for (int i = 0; i < node_list_length; ++i)
> {
> attribute = dynamic_cast<DOMElement*>(pNodes->item(i));
>
> child =
> dynamic_cast<DOMCharacterData*>(pNodes->item(i)->getFirstChild());
>
> cout << "Length: " << child->getLength() << endl;
> // if p_element is NULL the node is probably a comment
> if (child != NULL)
> {
> string text_string = XMLString::transcode(child->getData());
> AddString(key, text_string);
> .............
>
> child->GetData() returns an XMLCh* containing for example 'Slut på minne'.'
> But when I tried to use that string in SDL_ttf to print a UTF8 string on the
> screen it only works as long as the string contains ASCII charaters... When
> I put an å, ä or ö in it doesn't work...
> Also, when I try to print text_string with cout it doesn't work when I try
> to use special chatares...
>
> Thanks in advance... And sorry for taking up your time
> Daniel
>
> _________________________________________________________________
> MSN 8 with e-mail virus protection service: 2 months FREE*
> http://join.msn.com/?page=features/virus
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org