I'm trying to parse a XML file with UTF-8 encoded, I have figure out how to use Parser.XML module and it works fine.
But there is a problem, I can't write the UTF-8 string I read from the file, but I could use GTK2 module to display those string.
When I tried use write() to let it display on console, Pike compilan: ================================================= Stdio.File->write(): cannot output wide strings. _static_modules.files()->Fd: Fd(1)->write("\110112\61062\n") aa.pike:21: /home/brianhsu/aa()->main() =================================================
And when I use those string at the GTK2.Lable->create() , it also says : ================================================= Bad argument 1 to create(). Expected string (8bit). =================================================
But I can first create an empty label, then use set_text() to set the conent of the label.
Where should I check my code?
My XML file: http://stu.im.ncnu.edu.tw/~brianhsu/test.xml
Here is my code,I commemted out the code that have these problem. =================================================
import Parser.XML;
int main () { string xml = Stdio.read_file ( "test.xml" );
Tree.Node root = Tree.parse_input ( xml ); string test = root->get_children()[1]->get_tag_name();
GTK2.gtk_init(); GTK2.Window win = GTK2.Window( GTK2.WINDOW_TOPLEVEL );
win->set_default_size ( 320 , 240 );
// Faild //GTK2.Label lab = GTK2.Label ( test );
// Faild //write ( test + "\n" );
GTK2.Label lab = GTK2.Label ( "" );
lab->set_text ( test ); win->set_title ( test );
win->add ( lab ); win->show_all();
return -1;
} ===================================================
在 2005/8/13,墳墓 brianhsu.hsu@gmail.com 撰寫:
I'm trying to parse a XML file with UTF-8 encoded, I have figure out how to use Parser.XML module and it works fine.
But there is a problem, I can't write the UTF-8 string I read from the file, but I could use GTK2 module to display those string.
When I tried use write() to let it display on console, Pike compilan:
Stdio.File->write(): cannot output wide strings. _static_modules.files()->Fd: Fd(1)->write("\110112\61062\n") aa.pike:21: /home/brianhsu/aa()->main() =================================================
Sloved.
I missunderstood utf8_to_string and string_to_utf8. I works fine with converting it using string_to_utf8
pike-devel@lists.lysator.liu.se