Hello all,
I needed to read contents of an UTF8 encoded file in C++ (gcc version
3.3.5 on Linux). I decided to do it the C++ way, using streams:
-------------
std::locale utf8loc("en_US.utf8");
std::wifstream ifs("smthg");
ifs.imbue(utf8loc);
std::wstring item;
while (ifs >item) {
here
}
------------
but the inner block ("here") never gets executed. I tried searching
around the web and my head spins, surely doing such mundane,
straightforward task cannot be that complicated in C++? What am I
doing wrong please? What should I test for, look out for?
Cheers.
To narrow down my problem:
* I don't want to use any non-standard functions, libraries etc.
* the input file is in UTF8, I want to read (parts of) its contents as
wstring
---------------
$ locale -a
C
POSIX
en_GB.utf8
en_US.utf8 2 3909
On Feb 5, 7:53 am, koara <ko...@atlas.czwrote:
Hello all,
I needed to read contents of an UTF8 encoded file in C++ (gcc version
3.3.5 on Linux). I decided to do it the C++ way, using streams:
-------------
std::locale utf8loc("en_US.utf8");
std::wifstream ifs("smthg");
ifs.imbue(utf8loc);
std::wstring item;
while (ifs >item) {
here
}
------------
but the inner block ("here") never gets executed. I tried searching
around the web and my head spins, surely doing such mundane,
straightforward task cannot be that complicated in C++? What am I
doing wrong please? What should I test for, look out for?
Cheers.
To narrow down my problem:
* I don't want to use any non-standard functions, libraries etc.
* the input file is in UTF8, I want to read (parts of) its contents as
wstring
---------------
$ locale -a
C
POSIX
en_GB.utf8
en_US.utf8
Mayhaps the file "smthg" does not contain text that is convertable to
a wstring? or no text at all?
What's in the file? Also did you ever check if it actually got opened?
Is it in the proper directory?
On Feb 5, 5:15 pm, Christopher <cp...@austin.rr.comwrote:
Mayhaps the file "smthg" does not contain text that is convertable to
a wstring?
No. It contains text convertible to wstring.
What's in the file? Also did you ever check if it actually got opened?
Yes I did, problem is not in file opening.
File contains text with national characters (cz, de).
Cheers. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mike Dee |
last post by:
A very very basic UTF-8 question that's driving me nuts:
If I have this in the beginning of my Python script in Linux:
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
should I - or should I...
|
by: Sarah Akers |
last post by:
GgF
----gL5cJ72EqiGIQ0SK65Rz
Content-Type: text/html;
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<style type=3D"text/css">.eyebrow { FONT-WEIGHT: bold; FONT-SIZE: 10px; TE=
|
by: Blake Mandelbaum |
last post by:
bgc
----mDuNni7bWv1kUF0gGK
Content-Type: text/html;
Content-Transfer-Encoding: quoted-printable
<html><head><style type=3Dtext/css>.eyebrow { FONT-WEIGHT: bold; FONT-SIZE=
: 10px;...
|
by: Manolatos Tilemahos |
last post by:
Dear friends,
First pls accept my apologies, because I am a new Postgres user, so my
questions could be silly.
We need to setup a database using UTF-8 encoding, however, by some way, we
have...
|
by: anubis |
last post by:
Heay, i've got this problem:
http://rafb.net/paste/results/lpNgbn49.html
i'm using wifstream to read utf-16 file and i've got this problem, that
each byte is read into seperate char while...
|
by: Niels |
last post by:
Whenever I enter a line with spaces in a cin >> .. line my program seems
to skip all cin lines after that point. Could someone please explain me
why this is? I'm calling this procedure from main,...
|
by: toton |
last post by:
Hi,
I have my program using wstring everywhere instead of string.
Similarly I need to process some file, which contains unicode or ascii
character. I need to stream them. Thus I use wifstream etc....
|
by: Soumen |
last post by:
I wanted convert a mixed case string to a lower case one. And I tried
following code:
std::transform(mixedCaseString.begin(), mixedCaseString::end(),
mixedCaseString.begin(),...
|
by: mathieu |
last post by:
Hi,
I am playing with the following C++ piece of code (*). At least on
my system debian/gcc 4.3 it looks like I am not writing out a floating
point separator as a comma. what are the operation...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |