when I use "target_len = len;", the result in GBK is something contains the right chars and some unrelated ones, but when use "target_len = 2*len;" or "target_len = len+1;", every thing is ok.
I think the source encode UTF-8 is using 3 bytes for Chinese char, but GBK will use 2 bytes, so in "target_len = len;", the target_len will be enough large, but the result did not show that.
Thanks!
I miss the basic usage of strlen()!
And I recalled that problem just happened when source char is English, but not Chinese! because when Chinese char, GBK uses 2 bytes, but when English char, it uses 1 byte, and the same time UTF-8 uses 1 byte too when English char, so I miss strlen() when dealing with English chars!
Thanks again.
Best Regards
Zhimin