473,322 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Language support (UTF-8 with std::string and std::cout) help

I want to be able to print out (and read in) characters with accents
(for example French and Italian text). So far I have this:
std::locale lang (getenv ("LANG"));

which seems to set the locale correctly, say to it_IT.utf8 (on UNIX).

However, when reading in text from a file using:

std::string input;
std::copy (istream_iterator<char> (file), istream_iterator<char> (),
back_inserter (input));

and then using std::cout at certain subscripts or indicies within the
string the ones with accents appear like this:

<A0>
<A8>

etc.

What am I doing wrong? What to I need to do in order to process the
text correctly?

Thanks

James Vanns
Jul 22 '05 #1
1 3373
"James Vanns" <ji**@canterbury.ac.uk> wrote in message
news:2d**************************@posting.google.c om...
I want to be able to print out (and read in) characters with accents
(for example French and Italian text). So far I have this:
std::locale lang (getenv ("LANG"));

which seems to set the locale correctly, say to it_IT.utf8 (on UNIX).

However, when reading in text from a file using:

std::string input;
std::copy (istream_iterator<char> (file), istream_iterator<char> (),
back_inserter (input));

and then using std::cout at certain subscripts or indicies within the
string the ones with accents appear like this:

<A0>
<A8>

etc.

What am I doing wrong? What to I need to do in order to process the
text correctly?


Looks to me like you're getting one of the ISO-8859-x character
sets for your troubles. These are all 256-byte character sets that
give different meanings for different European cultures to the last
128 elements. If you want *that* converted to UTF-8, you need a
codecvt facet that will do the job. We have such a set of facets
in our CoreX library. If you don't want to walk that path, you've
got some information scrounging and code writing ahead of you.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dave | last post by:
Hi All, I have a VS.NET 2003 solution that uses several setup projects to package various components and applications into MSI files. I need to provide foreign language support for 5-6 languages...
3
by: Kieran Green | last post by:
Greetings, We are building an application written for Windows in C++ which uses OLEDB to connect to AIX DB2 8.2. Our app stores all string data in the wchar_t datatype, which generates dynamic...
0
by: Paul T. Rong | last post by:
Dear All, I would like to use MOD 2000 English version to pack a mdb file which I made under Chinese Access 2000.The key problem is to change the English runtime to the Chinese one. I was told...
1
by: Hari Shankar | last post by:
Dear all I am supposed to develop a world ready application in C# 2003 (which will run in xp) which should aupport Arabic & Hebrew also. My doubts(Fears) are: 1. Do i have to create all the...
2
by: Calvin Lai | last post by:
Hi all, I have a serious problem with the application I am developing. The language I used are mainly English, and some Chinese. (But I guess this problem happens accross different language). ...
2
by: perspolis | last post by:
Hi all I wanted to know when I create a form ,Where does The VS.Net keep string literals on form?? I want to have a form for some languages..Do I have to design a form for every language?or can I...
1
by: praveenkhade | last post by:
The Visual Studio language support for C# has not been installed. Code editing intellisense will not be available. Markup intellisense for server controls I m getting this error, wat might be...
1
by: manojrajgarhia | last post by:
Operating Environment: XP US English Developement Environment: VS 2005 C# Our applications needs to support keyboard input for multiple languages. Code snippet for our proof of concept is as...
1
by: =?Utf-8?B?VGVkbW9uZA==?= | last post by:
Dear all, My colleague has created a Web project that support both English and Chinese. We use the Local Resource to keep the display values. However, when I run the project in my PC, I get a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.