设计记录器库可用于UNICODE和MBCS [英] Designing logger Library can be used for both UNICODE and MBCS

查看:61
本文介绍了设计记录器库可用于UNICODE和MBCS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个带有某些API的库(Windows),可以通过任何程序轻松加载,并有助于创建日志文件。我希望我的库得到Unicode和MBCS的支持。

例如:任何unicode项目都可以加载它并使用并发送一个unicode字符串来记录它。同样地,任何MBCS项目也可以用MBCS字符串表示



任何人都可以告诉我如何实现这个吗?





谢谢

解决方案

MBCS不是任何特定的编码。特别是,Unicode UTF-8和UTF-16也被归类为MBCS: http://en.wikipedia.org/wiki / multi-byte_character_set [ ^ ]。



在这方面,这个问题毫无意义,因为你没有指定你需要什么非Unicode MBCS编码以及为什么。但是我们假设您真的有几种不同的编码可供使用(很难想象为什么,如果该库只适用于Windows)。



我认为它不能任何实际意义。所有客户端都可以将任何字符串转换为Unicode并呼叫您的设施。或者,您需要发送数据以及指示所使用的编码的一些参数,并且库应该处理它。



-SA

I want to create a Library (Windows) with some API that can be easily loaded by any program and will help creating log files. I want my Library to be Supported both by Unicode and MBCS.
Ex: Any unicode project can load this and use and send a unicode string to log it. Similarly any MBCS project can also do same with MBCS string

Can any one tell me how to implement this?


Thanks

解决方案

MBCS is not any specific encoding. In particular, Unicode UTF-8 and UTF-16 are also classified as MBCS: http://en.wikipedia.org/wiki/Multi-byte_character_set[^].

In this respect, the question makes no sense, as you did not specify what non-Unicode MBCS encoding do you need and why. But let's suppose you really have several different encodings to be used (hard to imagine why, if the library is for Windows only).

I don't think it can make any practical sense. All clients can translate any strings to Unicode and call your facility. Alternatively, you would need to send data along with some parameter indicating the encoding used, and the library should deal with it.

—SA


这篇关于设计记录器库可用于UNICODE和MBCS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆