UNICODE::ICONVERT::C(3)

✨ UNICODE::ICONVERT::C(3) ✨

okay so bestie, welcome to the Courier Unicode Library corner of the manual pages πŸ’– this one is unicode::iconvert::convert, plus a lil squad of charset constants: unicode::ucs_4, unicode::ucs_2, unicode::utf_8, and unicode::iso_8859_1 πŸ¦‹ the whole vibe is unicode character set conversion, and honestly? it's giving essential.


🌸 NAME 🌸

unicode::iconvert::convert, unicode::ucs_4, unicode::ucs_2, unicode::utf_8, unicode::iso_8859_1 β€” unicode character set conversion πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <courier-unicode.h>

extern const char unicode::ucs_4[];
extern const char unicode::ucs_2[];
extern const char unicode::utf_8[];
extern const char unicode::iso_8859_1[];

std::string unicode::iconvert::convert(const std::string_view &text,
                                       const std::string &srccharset,
                                       const std::string &dstcharset);

std::string unicode::iconvert::convert(const std::string_view &text,
                                       const std::string &srccharset,
                                       const std::string &dstcharset,
                                       bool &errflag);

std::string unicode::iconvert::convert(const std::u32string_view &text,
                                       const std::string &dstcharset);

std::string unicode::iconvert::convert(const std::u32string_view &text,
                                       const std::string &dstcharset,
                                       bool &errflag);

bool unicode::iconvert::convert(const std::string_view &text,
                                const std::string &charset,
                                std::u32string &text);

πŸ’œ DESCRIPTION πŸ’œ

so the unicode::convert::convert() functions are overloaded (main character energy, obviously πŸ‘‘) and here's what they convert:

  • a text string going from one supported character set to another one, and you get the brand new string back πŸ’«
  • a Unicode string turning into a character string in a supported character set 🌈
  • or they initialize a Unicode string β€” passed on in by reference β€” by converting a text string from a given character set over to unicode 🧚

these functions are lowkey powered by iconv(3), and they can handle any character set that iconv(3) supports. no cap ✨

use unicode::ucs_2 and unicode::ucs_4 when you wanna specify the 16 and the 32 bit unicode octet in native byte order πŸŽ€ and use unicode::utf_8 and unicode::iso_8859_1 to specify these two standard character sets πŸ’–

now for the flag stuff: the overloaded versions that pass a reference to a bool set that flag to true if some characters could not be converted 😭 and the overloaded version that initializes a unicode vector returns that bool flag instead πŸ™ˆ periodt.


🌟 SEE ALSO 🌟

courier-unicode(7), unicode::convert::convert_tocase(3), unicode_convert(3), iconv(3). go read them, iykyk πŸ“š


πŸ’– AUTHOR πŸ’–

Sam Varshavchik β€” Author 🫢


Courier Unicode Library Β· 04/12/2026 β€” ok bye bestie, go convert some charsets, you're literally gonna slay πŸ’…βœ¨πŸŒˆπŸ¦‹πŸ’œ

πŸ“¦ where this page comes from