Date: Tue, 13 Oct 2015 02:29:38 -0700 (MST) From: kora <kora.jenkins@googlemail.com> To: freebsd-questions@freebsd.org Subject: Re: How to get libiconv on FreeBSD 10 convert utf-8 -> wchar_t ? Message-ID: <1444728578150-6044683.post@n5.nabble.com> In-Reply-To: <1444723053047-6044663.post@n5.nabble.com> References: <1443688672992-6042436.post@n5.nabble.com> <20151001212047.1f79e315@kalimero.tijl.coosemans.org> <1444723053047-6044663.post@n5.nabble.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi there,
I solved it.
I didn't notice that wchar_t is system dependent !
I wrote a helpermethod to return the correct wchar_t "tocode" / "fromcode"
input for the iconv_open().
Using it now works.
#define WCHAR_32_LE "UTF-32LE"
#define WCHAR_32_BE "UTF-32BE"
#define WCHAR_16_LE "UTF-16LE"
#define WCHAR_16_BE "UTF-16BE"
const char* systemWCharType(){
if (NULL == mySystemsWCharType){
int wCharSize = sizeof(wchar_t);
int num = 1;
if(*(char *)&num == 1){
if (4 == wCharSize){
mySystemsWCharType = WCHAR_32_LE;
}
else{
mySystemsWCharType = WCHAR_16_LE;
}
}
else{
if (4 == wCharSize){
mySystemsWCharType = WCHAR_32_BE;
}
else{
mySystemsWCharType = WCHAR_16_BE;
}
}
}
return mySystemsWCharType;
}
Thanks for support
Kora
--
View this message in context: http://freebsd.1045724.n5.nabble.com/How-to-get-libiconv-on-FreeBSD-10-convert-utf-8-wchar-t-tp6042436p6044683.html
Sent from the freebsd-questions mailing list archive at Nabble.com.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1444728578150-6044683.post>
