[gtkmm] How can I dump a UTF8 text file into Glib::ustring ?
- From: Brian =?big5?b?SHN1?= (=?big5?b?pWq507xDpVA=?=) <brianhsu bone twbbs org tw>
- To: gtkmm-list gnome org
- Subject: [gtkmm] How can I dump a UTF8 text file into Glib::ustring ?
- Date: Wed, 20 Aug 2003 09:16:53 +0800
Hello everyone,
I'm trying to write a simple template library using Glib::ustring in order to handle
unicode files and strings.
But now I have a problem that deal with Glib::ustring and file I/O,
I can't read a UTF8 text file into a Glib::ustring.
I'v tried read file using standard C++ I/O library , dump the file
character by character to the std::string. But when I assign this
std::string to Glib::ustring , it will crash even the file only have
ascii charset in it.
I'v also tried using code that present in example/markup/parser.cc :
void file_get_contents(const std::string& filename, Glib::ustring& contents)
{
const Glib::RefPtr<Glib::IOChannel> channel = Glib::IOChannel::create_from_file(filename, "r");
channel->read_to_end(contents);
}
It work prefectly when the file only contain ascii character ,
but if the file have something other than ascii ( like Chinese/Japanese in UTF8 ) ,
it will crash.
Would any one like to tell me how to read hole UTF8 text file into Glib::ustring?
Sorry for my poor English,
Brian Hsu.
--
~ Brian Hsu (¥j¹Ó¼C¥P)
'v' E-Mail : brianhsu at bone.twbbs.org.tw
// \\ WWW HomePage : http://bone.twbbs.org.tw/
/( )\ PGP Public Key : http://bone.twbbs.org.tw/PGP
^`~'^ Je t'aime ¤ ӧڤߤ¤ªº¤p¯µ±K¡C
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]