By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,120 Members | 1,257 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,120 IT Pros & Developers. It's quick & easy.

string locale aware?

P: n/a
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
Jul 29 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
"Bob Smith" <bo*******@marketweighton.com> wrote in message
news:dc**********@phys-news1.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
Jul 29 '05 #2

P: n/a
P.J. Plauger wrote:
"Bob Smith" <bo*******@marketweighton.com> wrote in message
news:dc**********@phys-news1.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
Jul 29 '05 #3

P: n/a
"Bob Smith" <bo*******@marketweighton.com> wrote in message
news:dc**********@phys-news1.kolumbus.fi...
P.J. Plauger wrote:
"Bob Smith" <bo*******@marketweighton.com> wrote in message
news:dc**********@phys-news1.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
Jul 29 '05 #4

P: n/a

"Bob Smith" <bo*******@marketweighton.com> skrev i en meddelelse
news:dc**********@phys-news1.kolumbus.fi...
P.J. Plauger wrote:
"Bob Smith" <bo*******@marketweighton.com> wrote in message
news:dc**********@phys-news1.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
Jul 29 '05 #5

P: n/a
Peter Koch Larsen wrote:

"Bob Smith" <bo*******@marketweighton.com> skrev i en meddelelse
news:dc**********@phys-news1.kolumbus.fi...
P.J. Plauger wrote:
"Bob Smith" <bo*******@marketweighton.com> wrote in message
news:dc**********@phys-news1.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
"frvrngda". ....
any ideas much appreciated
--
http://www.kolumbus.fi/bob.smith
Jul 29 '05 #6

P: n/a
P.J. Plauger wrote:
"Bob Smith" <bo*******@marketweighton.com> wrote in message
news:dc**********@phys-news1.kolumbus.fi...
P.J. Plauger wrote:
"Bob Smith" <bo*******@marketweighton.com> wrote in message
news:dc**********@phys-news1.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.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com


--
http://www.kolumbus.fi/bob.smith
Jul 29 '05 #7

P: n/a
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
"frvrngda". ....
any ideas much appreciated


Are you sure libxml2 is parsing correctly? Have you printed the
strings before placing them in a std::string?

Jul 29 '05 #8

P: n/a
Bob Smith wrote:
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
"frvrngda". ....
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.
Jul 29 '05 #9

P: n/a
tedu wrote:
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
"frvrngda". ....
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
Jul 30 '05 #10

P: n/a
Bob Smith sade:
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.
Jul 30 '05 #11

P: n/a
Bob Smith wrote:
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
Jul 30 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.