Dear all,
As mentioned in my previous post, AbiWord 1.1.x (GTK2 on GNU/Linux)
would fail to display the text in some dialog boxes when started under
a non-UTF8 locale (say zh_TW.Big5, zh_CN.GB2312). All is normal in
zh_TW.UTF-8 locale.
I was perplexed as to why some Chinese strings display properly, and some
don't, with the error:
WARNING **: Invalid UTF8 string passed to pango_layout_set_text()
After some investigation, it turns out to be a difference in the call to
wctomb_conv() between XAP_DiskStringSet::setValue() and
AP_DiskStringSet::setValue().
Tomas Frydrych's commit to xap_Strings.cpp in January 2002 (to fix Bug 2570):
http://www.abisource.com/bonsai/cvsview2.cgi?diff_mode=context&whitespace_mode=show&root=/cvsroot&subdir=abi/src/af/xap/xp&command=DIFF_FRAMESET&file=xap_Strings.cpp&rev2=1.23&rev1=1.22
Christian Biesel's commit to ap_Strings.cpp in October 2002
http://www.abisource.com/bonsai/cvsview2.cgi?diff_mode=context&whitespace_mode=show&root=/cvsroot&subdir=abi/src/wp/ap/xp&command=DIFF_FRAMESET&file=ap_Strings.cpp&rev2=1.14&rev1=1.13
So, XAP_DiskStringSet::setValue() was storing the strings in the current
system encoding, e.g. when LANG=zh_TW.Big5, it stores the strings in Big5
encoding; whereas AP_DiskStringSet::setValue() does the right thing by
storing the text in UTF-8 encoding. (Or something like that; I don't fully
understand the details.)
So, I changed xap_Strings.cpp to use the line in ap_Strings.cpp, and
voila, it works! :-) Patch is attached. I hope the change won't break
things on other platforms.
Cheers,
Anthony
--
Anthony Fok Tung-Ling
ThizLinux Laboratory <[EMAIL PROTECTED]> http://www.thizlinux.com/
Debian Chinese Project <[EMAIL PROTECTED]> http://www.debian.org/intl/zh/
Come visit Our Lady of Victory Camp! http://www.olvc.ab.ca/
--- abiword-1.1.3+cvs.2003.03.02.orig/abi/src/af/xap/xp/xap_Strings.cpp
+++ abiword-1.1.3+cvs.2003.03.02/abi/src/af/xap/xp/xap_Strings.cpp
@@ -250,11 +250,15 @@
}
}
+#if 0
const char * encoding =
(XAP_EncodingManager::get_instance()->getNativeSystemEncodingName()) ?
XAP_EncodingManager::get_instance()->getNativeSystemEncodingName() :
XAP_EncodingManager::get_instance()->getNativeEncodingName();
UT_Wctomb wctomb_conv(encoding);
+#else
+ UT_Wctomb wctomb_conv(XAP_App::getApp()->getDefaultEncoding());
+#endif
char letter_buf[20];
int length;
for (int k=0; k<kLimit; k++)