 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Bob Smith Guest
|
Posted: Fri Jul 29, 2005 4:53 am Post subject: string locale aware? |
|
|
hi all,
having some problem with locale. I use an std::string, but seems like not
locale aware åäö = garbage. How do I make the string aware of my
scandi-locale? TIA
--
http://www.kolumbus.fi/bob.smith
|
|
| Back to top |
|
 |
P.J. Plauger Guest
|
Posted: Fri Jul 29, 2005 11:29 am Post subject: Re: string locale aware? |
|
|
"Bob Smith" <bobsmith1 (AT) marketweighton (DOT) com> wrote
| Quote: | having some problem with locale. I use an std::string, but seems like not
locale aware åäö = garbage. How do I make the string aware of my
scandi-locale? TIA
|
How will it behave differently once it's "locale aware"?
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
|
|
| Back to top |
|
 |
P.J. Plauger Guest
|
Posted: Fri Jul 29, 2005 2:54 pm Post subject: Re: string locale aware? |
|
|
"Bob Smith" <bobsmith1 (AT) marketweighton (DOT) com> wrote
| Quote: | P.J. Plauger wrote:
"Bob Smith" <bobsmith1 (AT) marketweighton (DOT) com> wrote in message
news:dcc4jp$kch$1 (AT) phys-news1 (DOT) kolumbus.fi...
having some problem with locale. I use an std::string, but seems like
not
locale aware åäö = garbage. How do I make the string aware of my
scandi-locale? TIA
How will it behave differently once it's "locale aware"?
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
it will support åäöÅÄÖ, which it fails to handle right now.
|
You mean, you can't insert such a sequence into a string?
Bet you can. Of course, whether each of those glyphs shown
above is represented as one or more elements of the string
depends on a whole bunch of factors. But you still haven't
defined what you mean by "support."
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
|
|
| Back to top |
|
 |
Peter Koch Larsen Guest
|
Posted: Fri Jul 29, 2005 2:56 pm Post subject: Re: string locale aware? |
|
|
"Bob Smith" <bobsmith1 (AT) marketweighton (DOT) com> skrev i en meddelelse
news:dcdfig$ftl$1 (AT) phys-news1 (DOT) kolumbus.fi...
| Quote: | P.J. Plauger wrote:
"Bob Smith" <bobsmith1 (AT) marketweighton (DOT) com> wrote in message
news:dcc4jp$kch$1 (AT) phys-news1 (DOT) kolumbus.fi...
having some problem with locale. I use an std::string, but seems like
not
locale aware åäö = garbage. How do I make the string aware of my
scandi-locale? TIA
How will it behave differently once it's "locale aware"?
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
it will support åäöÅÄÖ, which it fails to handle right now.
--
http://www.kolumbus.fi/bob.smith
|
What do you mean by "fails to handle"? I'm sure that if you have this code:
std::string s("æøå");
for (size_t i = 0; i < s.size); ++i) std::cout << s[i] << ": " << int(s[i])
<< n;
You would find three ints outputted - giving you the decimal value of three
"scandinavian" characters.
/Peter
|
|
| Back to top |
|
 |
Bob Smith Guest
|
Posted: Fri Jul 29, 2005 5:07 pm Post subject: Re: string locale aware? |
|
|
P.J. Plauger wrote:
| Quote: | "Bob Smith" <bobsmith1 (AT) marketweighton (DOT) com> wrote in message
news:dcc4jp$kch$1 (AT) phys-news1 (DOT) kolumbus.fi...
having some problem with locale. I use an std::string, but seems like not
locale aware åäö = garbage. How do I make the string aware of my
scandi-locale? TIA
How will it behave differently once it's "locale aware"?
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
it will support åäöÅÄÖ, which it fails to handle right now. |
--
http://www.kolumbus.fi/bob.smith
|
|
| Back to top |
|
 |
tedu Guest
|
Posted: Fri Jul 29, 2005 5:54 pm Post subject: Re: string locale aware? |
|
|
Bob Smith wrote:
| Quote: | I don't know where i am going wrong, I'm parsing rss feeds with libxml2, and
after handling the parsed contents with std::strings the scandics are
"förvrängda". ....
any ideas much appreciated
|
Are you sure libxml2 is parsing correctly? Have you printed the
strings before placing them in a std::string?
|
|
| Back to top |
|
 |
Bob Smith Guest
|
Posted: Fri Jul 29, 2005 6:07 pm Post subject: Re: string locale aware? |
|
|
Peter Koch Larsen wrote:
| Quote: |
"Bob Smith" <bobsmith1 (AT) marketweighton (DOT) com> skrev i en meddelelse
news:dcdfig$ftl$1 (AT) phys-news1 (DOT) kolumbus.fi...
P.J. Plauger wrote:
"Bob Smith" <bobsmith1 (AT) marketweighton (DOT) com> wrote in message
news:dcc4jp$kch$1 (AT) phys-news1 (DOT) kolumbus.fi...
having some problem with locale. I use an std::string, but seems like
not
locale aware åäö = garbage. How do I make the string aware of my
scandi-locale? TIA
How will it behave differently once it's "locale aware"?
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
it will support åäöÅÄÖ, which it fails to handle right now.
--
http://www.kolumbus.fi/bob.smith
What do you mean by "fails to handle"? I'm sure that if you have this
code:
std::string s("æøå");
for (size_t i = 0; i < s.size); ++i) std::cout << s[i] << ": "
int(s[i]) << n;
You would find three ints outputted - giving you the decimal value of
three "scandinavian" characters.
/Peter
hmm, |
I don't know where i am going wrong, I'm parsing rss feeds with libxml2, and
after handling the parsed contents with std::strings the scandics are
"förvrängda". ....
any ideas much appreciated
--
http://www.kolumbus.fi/bob.smith
|
|
| Back to top |
|
 |
Bob Smith Guest
|
Posted: Fri Jul 29, 2005 6:16 pm Post subject: Re: string locale aware? |
|
|
P.J. Plauger wrote:
| Quote: | "Bob Smith" <bobsmith1 (AT) marketweighton (DOT) com> wrote in message
news:dcdfig$ftl$1 (AT) phys-news1 (DOT) kolumbus.fi...
P.J. Plauger wrote:
"Bob Smith" <bobsmith1 (AT) marketweighton (DOT) com> wrote in message
news:dcc4jp$kch$1 (AT) phys-news1 (DOT) kolumbus.fi...
having some problem with locale. I use an std::string, but seems like
not
locale aware åäö = garbage. How do I make the string aware of my
scandi-locale? TIA
How will it behave differently once it's "locale aware"?
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
it will support åäöÅÄÖ, which it fails to handle right now.
You mean, you can't insert such a sequence into a string?
Bet you can. Of course, whether each of those glyphs shown
above is represented as one or more elements of the string
depends on a whole bunch of factors. But you still haven't
defined what you mean by "support."
|
I mean that using std::string for handling parsed contents from rss feeds
doesn't work. The scandinavian characters are not represented/shown as they
should.
--
http://www.kolumbus.fi/bob.smith
|
|
| Back to top |
|
 |
Jacob Guest
|
Posted: Fri Jul 29, 2005 9:30 pm Post subject: Re: string locale aware? |
|
|
Bob Smith wrote:
| Quote: | hmm,
I don't know where i am going wrong, I'm parsing rss feeds with libxml2, and
after handling the parsed contents with std::strings the scandics are
"förvrängda". ....
any ideas much appreciated
|
On what reason to you conclude it is not correct?
It is a common error to view such strings in the
console, a DB or a GUI system, and forgetting that
it is the console/DB/GUI system that behaves incorrect.
|
|
| Back to top |
|
 |
Tobias Blomkvist Guest
|
Posted: Sat Jul 30, 2005 12:44 pm Post subject: Re: string locale aware? |
|
|
Bob Smith sade:
| Quote: | hi all,
having some problem with locale. I use an std::string, but seems like not
locale aware åäö = garbage. How do I make the string aware of my
scandi-locale? TIA
|
Produce an output-filter that translates the wrong codes to
the correct (Latin-1?) codes.
That's how I'm forced to do it for correct printing since BCB insists
on using a window charset instead of Latin-1 when compiling.
Tobias
--
IMPORTANT: The contents of this email and attachments are confidential
and may be subject to legal privilege and/or protected by copyright.
Copying or communicating any part of it to others is prohibited and may
be unlawful.
|
|
| Back to top |
|
 |
Bob Smith Guest
|
Posted: Sat Jul 30, 2005 2:42 pm Post subject: Re: string locale aware? |
|
|
tedu wrote:
| Quote: | Bob Smith wrote:
I don't know where i am going wrong, I'm parsing rss feeds with libxml2,
and after handling the parsed contents with std::strings the scandics are
"förvrängda". ....
any ideas much appreciated
Are you sure libxml2 is parsing correctly? Have you printed the
strings before placing them in a std::string?
I checked teh output during parse, and it does not there either show åäö |
hmmm, now, the locale on my linux is sv_SV, seems to be correct,
I have also a problem with my webserver, when serving pages the same thing
happens on the client (windows), the documents åäö are gone, now this has
nothing to do with C++ but I'd be grateful if someone has ideas as hwo to
solve this problem as the two seem related.
--
http://www.kolumbus.fi/bob.smith
|
|
| Back to top |
|
 |
Matthias Kaeppler Guest
|
Posted: Sat Jul 30, 2005 2:55 pm Post subject: Re: string locale aware? |
|
|
Bob Smith wrote:
| Quote: | Are you sure libxml2 is parsing correctly? Have you printed the
strings before placing them in a std::string?
I checked teh output during parse, and it does not there either show åäö
hmmm, now, the locale on my linux is sv_SV, seems to be correct,
I have also a problem with my webserver, when serving pages the same thing
happens on the client (windows), the documents åäö are gone, now this has
nothing to do with C++ but I'd be grateful if someone has ideas as hwo to
solve this problem as the two seem related.
|
Where are you outputting/displaying the strings? It's most probably an
issue with your environment, not std::string.
Make sure that the medium you use to display the text is aware of your
locale and that it uses a font which is able to render these characters.
For example, if you don't see the special characters on your console,
try installing transcoded font sets for X specific to your locale. This
is how I managed to display German Umlauts on a UNIX console.
--
Matthias Kaeppler
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|