Skip to content

andrewstalin/babel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Build Status

Babel is the library for encoding/decoding strings. Used for convert iconv and implementation using Win32 API by Yukihiro Nakadaira.

Example

Using Encoding type

const std::string str_utf16_be = "...";
auto enc = Encoding::open("UTF-16BE", "UTF-8");
std::string result(enc.encoding_size(str_utf16_be.c_str(), str_utf16_be.size()), 0);
enc.encode(str_utf16_be.c_str(), str_utf16_be.size()), const_cast<char*>(result.data()), result.size());

Using encode function

const std::string str_utf16_be = "...";
auto str = babel::encode("UTF-16BE", "UTF-8", str_utf16_be.c_str(), str_utf16_be.size());

Using for convert single-byte to multi-byte and vise versa (for Windows only).

// convert UTF-8 string to wide string
std::wstring str = babel::string_cast(u8"Привет, мир!", 65001);

// convert wide string to WINDOWS-1251 string
std::string str = babel::string_cast(L"Привет, мир!", "WINDOWS-1251");

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published