Boost.Nowide
Classes | Typedefs | Functions | Variables
boost::nowide Namespace Reference

This namespace includes implementation of the standard library functios such that they accept UTF-8 strings on Windows. On other platforms it is just an alias of std namespace (i.e. not on Windows) More...

Classes

class  args
 args is a class that fixes standard main() function arguments and changes them to UTF-8 under Microsoft Windows. More...
 
class  basic_filebuf
 This forward declaration defined the basic_filebuf type. More...
 
class  basic_filebuf< char >
 This is implementation of std::filebuf. More...
 
class  basic_fstream
 Same as std::basic_fstream<char> but accepts UTF-8 strings under Windows. More...
 
class  basic_ifstream
 Same as std::basic_ifstream<char> but accepts UTF-8 strings under Windows. More...
 
class  basic_ofstream
 Same as std::basic_ofstream<char> but accepts UTF-8 strings under Windows. More...
 
class  basic_stackstring
 A class that allows to create a temporary wide or narrow UTF strings from wide or narrow UTF source. More...
 
class  utf8_codecvt
 
class  utf8_codecvt< CharType, 2 >
 
class  utf8_codecvt< CharType, 4 >
 

Typedefs

typedef basic_filebuf< char > filebuf
 Convinience typedef. More...
 
typedef basic_ifstream< char > ifstream
 
typedef basic_ofstream< char > ofstream
 
typedef basic_fstream< char > fstream
 
typedef basic_stackstring< wchar_t, char, 256 > wstackstring
 
typedef basic_stackstring< char, wchar_t, 256 > stackstring
 
typedef basic_stackstring< wchar_t, char, 16 > wshort_stackstring
 
typedef basic_stackstring< char, wchar_t, 16 > short_stackstring
 

Functions

char * getenv (char const *key)
 UTF-8 aware getenv. Returns 0 if the variable is not set. More...
 
int setenv (char const *key, char const *value, int override)
 UTF-8 aware setenv, key - the variable name, value is a new UTF-8 value,. More...
 
int unsetenv (char const *key)
 Remove enviroment variable key.
 
int putenv (char *string)
 UTF-8 aware putenv implementation, expects string in format KEY=VALUE.
 
template<typename CharOut , typename CharIn >
CharOut * basic_convert (CharOut *buffer, size_t buffer_size, CharIn const *source_begin, CharIn const *source_end)
 Template function that converts a buffer of UTF sequences in range [source_begin,source_end) to the output buffer of size buffer_size. More...
 
char * narrow (char *output, size_t output_size, wchar_t const *source)
 
char * narrow (char *output, size_t output_size, wchar_t const *begin, wchar_t const *end)
 
wchar_t * widen (wchar_t *output, size_t output_size, char const *source)
 
wchar_t * widen (wchar_t *output, size_t output_size, char const *begin, char const *end)
 
std::string narrow (wchar_t const *s)
 
std::wstring widen (char const *s)
 
std::string narrow (std::wstring const &s)
 
std::wstring widen (std::string const &s)
 
FILE * freopen (char const *file_name, char const *mode, FILE *stream)
 Same as freopen but file_name and mode are UTF-8 strings. More...
 
FILE * fopen (char const *file_name, char const *mode)
 Same as fopen but file_name and mode are UTF-8 strings. More...
 
int rename (char const *old_name, char const *new_name)
 Same as rename but old_name and new_name are UTF-8 strings. More...
 
int remove (char const *name)
 Same as rename but name is UTF-8 string. More...
 
int system (char const *cmd)
 
 BOOST_STATIC_ASSERT (sizeof(std::mbstate_t)>=2)
 
void nowide_filesystem ()
 

Variables

details::winconsole_istream cin
 Same as std::cin, but uses UTF-8. More...
 
details::winconsole_ostream cout
 Same as std::cout, but uses UTF-8. More...
 
details::winconsole_ostream cerr
 Same as std::cerr, but uses UTF-8. More...
 
details::winconsole_ostream clog
 Same as std::clog, but uses UTF-8. More...
 

Detailed Description

This namespace includes implementation of the standard library functios such that they accept UTF-8 strings on Windows. On other platforms it is just an alias of std namespace (i.e. not on Windows)

Typedef Documentation

Convinience typedef.

Same as std::filebuf but accepts UTF-8 strings under Windows.

Same as std::fstream but accepts UTF-8 strings under Windows

Same as std::ifstream but accepts UTF-8 strings under Windows

Same as std::ofstream but accepts UTF-8 strings under Windows

Convinience typedef

typedef basic_stackstring<char,wchar_t,256> boost::nowide::stackstring

Convinience typedef

Convinience typedef

Convinience typedef

Function Documentation

template<typename CharOut , typename CharIn >
CharOut* boost::nowide::basic_convert ( CharOut *  buffer,
size_t  buffer_size,
CharIn const *  source_begin,
CharIn const *  source_end 
)

Template function that converts a buffer of UTF sequences in range [source_begin,source_end) to the output buffer of size buffer_size.

In case of success a NULL terminated string is returned (buffer), otherwise 0 is returned.

If there is not enough room in the buffer or the source sequence contains invalid UTF, 0 is returned, and the contents of the buffer are undefined.

FILE* boost::nowide::fopen ( char const *  file_name,
char const *  mode 
)
inline

Same as fopen but file_name and mode are UTF-8 strings.

If invalid UTF-8 given, NULL is returned and errno is set to EINVAL

FILE* boost::nowide::freopen ( char const *  file_name,
char const *  mode,
FILE *  stream 
)
inline

Same as freopen but file_name and mode are UTF-8 strings.

If invalid UTF-8 given, NULL is returned and errno is set to EINVAL

char* boost::nowide::getenv ( char const *  key)
inline

UTF-8 aware getenv. Returns 0 if the variable is not set.

This function is not thread safe or reenterable as defined by the standard library

char* boost::nowide::narrow ( char *  output,
size_t  output_size,
wchar_t const *  source 
)
inline

Convert NULL terminated UTF source string to NULL terminated output string of size at most output_size (including NULL)

In case of success output is returned, if the input sequence is illegal, or there is not enough room NULL is returned

char* boost::nowide::narrow ( char *  output,
size_t  output_size,
wchar_t const *  begin,
wchar_t const *  end 
)
inline

Convert UTF text in range [begin,end) to NULL terminated output string of size at most output_size (including NULL)

In case of success output is returned, if the input sequence is illegal, or there is not enough room NULL is returned

std::string boost::nowide::narrow ( wchar_t const *  s)
inline

Convert between Wide - UTF-16/32 string and UTF-8 string.

boost::locale::conv::conversion_error is thrown in a case of a error

std::string boost::nowide::narrow ( std::wstring const &  s)
inline

Convert between Wide - UTF-16/32 string and UTF-8 string

boost::locale::conv::conversion_error is thrown in a case of a error

void boost::nowide::nowide_filesystem ( )
inline

Instal utf8_codecvt facet into boost::filesystem::path such all char strings are interpreted as utf-8 strings

int boost::nowide::remove ( char const *  name)
inline

Same as rename but name is UTF-8 string.

If invalid UTF-8 given, -1 is returned and errno is set to EINVAL

int boost::nowide::rename ( char const *  old_name,
char const *  new_name 
)
inline

Same as rename but old_name and new_name are UTF-8 strings.

If invalid UTF-8 given, -1 is returned and errno is set to EINVAL

int boost::nowide::setenv ( char const *  key,
char const *  value,
int  override 
)
inline

UTF-8 aware setenv, key - the variable name, value is a new UTF-8 value,.

if override is not 0, that the old value is always overridded, otherwise, if the variable exists it remains unchanged

int boost::nowide::system ( char const *  cmd)
inline

Same as std::system but cmd is UTF-8.

If the input is not valid UTF-8, -1 returned and errno set to EINVAL

wchar_t* boost::nowide::widen ( wchar_t *  output,
size_t  output_size,
char const *  source 
)
inline

Convert NULL terminated UTF source string to NULL terminated output string of size at most output_size (including NULL)

In case of success output is returned, if the input sequence is illegal, or there is not enough room NULL is returned

wchar_t* boost::nowide::widen ( wchar_t *  output,
size_t  output_size,
char const *  begin,
char const *  end 
)
inline

Convert UTF text in range [begin,end) to NULL terminated output string of size at most output_size (including NULL)

In case of success output is returned, if the input sequence is illegal, or there is not enough room NULL is returned

std::wstring boost::nowide::widen ( char const *  s)
inline

Convert between UTF-8 and UTF-16 string, implemented only on Windows platform

boost::locale::conv::conversion_error is thrown in a case of a error

std::wstring boost::nowide::widen ( std::string const &  s)
inline

Convert between UTF-8 and UTF-16 string, implemented only on Windows platform

boost::locale::conv::conversion_error is thrown in a case of a error

Variable Documentation

details::winconsole_ostream boost::nowide::cerr

Same as std::cerr, but uses UTF-8.

Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio

details::winconsole_istream boost::nowide::cin

Same as std::cin, but uses UTF-8.

Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio

details::winconsole_ostream boost::nowide::clog

Same as std::clog, but uses UTF-8.

Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio

details::winconsole_ostream boost::nowide::cout

Same as std::cout, but uses UTF-8.

Note, the stream is not synchronized with stdio and not affected by std::ios::sync_with_stdio