Click here to Skip to main content
15,877,591 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
Posted
Updated 8-Sep-13 5:10am
v2

1 solution

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
 
Share this answer
 
Comments
iDebD 8-Sep-13 12:44pm    
In your last line I got your ans.
Sergey Alexandrovich Kryukov 8-Sep-13 14:57pm    
Great. Then I think you can accept it formally (green button).
—SA
pasztorpisti 8-Sep-13 15:25pm    
+5. I don't really like the term MBCS, many people think it is something that is not unicode (probably because you can choose mbcs and unicode from the same combobox in the VS project settings) while it is just a property of some encodings. It's better to make difference between encodings that can encode all unicode chars and encodings that can't. Today this is pretty much utf versus the rest of the encodings. I think using other than utf in serious programs for internal representation of strings is a bad practice.
Sergey Alexandrovich Kryukov 9-Sep-13 0:46am    
Thank you.

You are right. As I pointed out, MBCS is not an encoding, but just term describing some approach to encoding. But it is also important to understand, that Unicode is also not an encoding, even though it defines several different but equivalent encodings as some part of the standard.

Unicode in its code is the one-to-one correspondence between characters as cultural entities expressing some functions in the cultures, abstracted from glyph graphics and many other detail, and integer numbers (called code points) in the mathematical sense of this word, abstracted from computer representation of integer in bytes/bits. Additionally, "UTF" encodings standardize such computer representation.

This picture is itself poorly understood by many, but additional contribution to this confusion is Windows jargon, which calls "Unicode encoding" UTF-16LE, which is nothing more than the representation used for characters in memory by default. Amazingly, Windows API itself is pretty much well abstracted from this representation...

—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900