简体   繁体   English

跨平台unicode支持

[英]cross platform unicode support

I find that getting Unicode support in my cross-platform apps a real pain in the butt. 我发现在我的跨平台应用程序中获得Unicode支持是一个真正的痛苦。

I need strings that can go from C code, to a database, to a Java application and into a Perl module. 我需要可以从C代码到数据库,到Java应用程序和Perl模块的字符串。 Each of these use a different Unicode encodings (UTF8, UTF16) or some other code page. 其中每个都使用不同的Unicode编码(UTF8,UTF16)或其他一些代码页。 The biggest thing that I need is a cross-platform way of doing conversions. 我需要的最重要的事情是跨平台的转换方式。

What kind of tools, libraries or techniques do people use to make handling these things easier? 人们使用什么样的工具,库或技术来处理这些事情?

Have a look at this: http://www.icu-project.org/ 看看这个: http//www.icu-project.org/

Perl has Encode as a standard library. Perl将Encode作为标准库。 It can be used to read/write any encoding you want, so that's not going to be a problem. 它可以用来读/写你想要的任何编码,这样就不会有问题了。

How are you doing the cross-platform calls? 你是如何进行跨平台通话的? Is it all called from Java? 它是从Java调用的吗?

http://java.sun.com/docs/books/tutorial/i18n/text/string.html might be useful. http://java.sun.com/docs/books/tutorial/i18n/text/string.html可能很有用。

I'm a bit confused about exactly what you are trying to do. 我对你要做的事情有点困惑。 Is the database essentially interface between all the code? 数据库本质上是所有代码之间的接口吗? Then it should be easy - just make the DB UTF-8 and each of the clients will need to do their own conversions. 然后它应该很简单 - 只需使用数据库UTF-8,每个客户端都需要进行自己的转换。

Sounds like an interesting problem, could you share some more details? 听起来像一个有趣的问题,你能分享更多细节吗?

Well, I guess iconv is sufficient for your needs. 好吧,我猜iconv足以满足您的需求。 Iconv should be available on any POSIX system by default (those include (GNU/)Linux, *BSD, Mac OS X...). 默认情况下,Iconv应该可以在任何POSIX系统上使用(包括(GNU /)Linux,* BSD,Mac OS X ......)。 On Windows AFAIK it requires separate library but: 在Windows AFAIK上,它需要单独的库,但是:

  1. you may just install it/bundle with your software/static compile it. 你可以用你的软件安装它/ bundle / static编译它。 ( libiconv for windows ). libiconv for windows )。 (I'd guess I'd recommend to bundle it). (我猜我会建议捆绑它)。
  2. You may use some native Windows calls as special case. 您可以使用一些本机Windows调用作为特例。

Of course if you are using Java it has it built-in - but I see that it may not be what you want (JNI calls are expensive). 当然,如果您使用的是Java,它内置了它 - 但我发现它可能不是您想要的(JNI调用很昂贵)。

PS. PS。 Cannot you set perl to specific encoding? 你不能将perl设置为特定的编码吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM