Click here to Skip to main content
15,891,513 members
Articles / Programming Languages / C++

DynObj - C++ Cross Platform Plugin Objects

Rate me:
Please Sign up or sign in to vote.
4.95/5 (34 votes)
27 Sep 200727 min read 144.4K   3.4K   132  
DynObj is an open source library that provides a C++ application with run-time class loading facilities
#ifndef UNICODE_H
#define UNICODE_H

/*

// The documentation below comes from the fd32 project.
// The implementation is separate though.

A UTF-8 character is converted to a wide character (UTF-32 or UCS-4)
using the following rules (binary numbers):
\code
UTF-32                     - UTF-8
00000000 00000000 0aaaaaaa - 0aaaaaaa
00000000 00000bbb bbaaaaaa - 110bbbbb 10aaaaaa
00000000 ccccbbbb bbaaaaaa - 1110cccc 10bbbbbb 10aaaaaa
000dddcc ccccbbbb bbaaaaaa - 11110ddd 10cccccc 10bbbbbb 10aaaaaa
\endcode

A UTF-16 character is converted to a wide character (UTF-32 or UCS-4)
using the following rules (binary numbers):
\code
UTF-32                     - UTF-16
00000000 aaaaaaaa aaaaaaaa <-> aaaaaaaa aaaaaaaa
000bbbbb aaaaaaaa aaaaaaaa <-> 110110cc ccaaaaaa  110111aa aaaaaaaa
\endcode
where \c cccc = \c bbbbb - 1.

*/

// \brief  Returns the length in bytes of a UTF8 encoded character
// \param  lead_byte The first byte in the UTF8 encoded Unicode character
// \return Length 
int unicode_utf8_len_(char lead_byte);

// \brief One UTF8 encoded character is read and converted to an int
// \param s      The source buffer
// \param result Pointer to where to put result
// \return The number of bytes used to decode one Unicode character
int unicode_utf8_to_wchar_(int *result, const char *s);


// \brief One unicode character is converted to UTF8. 
// \param s     The destination buffer
// \param wc    Unicode character to be converted
// \param wsize Size of output buffer
// \return The length (in char) of the UTF8 encoded character
int unicode_wchar_to_utf8_(char *s, int wc, int size);

// \brief Convert to common case for string comparison
// \param wc    Unicode character to be converted
int unicode_simple_fold_( int wc );

#endif // UNICODE_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions