MPD  0.20.15
Functions
UTF8.hxx File Reference
#include "Compiler.h"
#include <stddef.h>
Include dependency graph for UTF8.hxx:

Go to the source code of this file.

Functions

gcc_pure gcc_nonnull_all bool ValidateUTF8 (const char *p) noexcept
 Is this a valid UTF-8 string? More...
 
gcc_const size_t SequenceLengthUTF8 (char ch) noexcept
 
gcc_pure size_t SequenceLengthUTF8 (const char *p) noexcept
 
gcc_pure gcc_nonnull_all const char * Latin1ToUTF8 (const char *src, char *buffer, size_t buffer_size) noexcept
 Convert the specified string from ISO-8859-1 to UTF-8. More...
 
gcc_nonnull_all char * UnicodeToUTF8 (unsigned ch, char *buffer) noexcept
 Convert the specified Unicode character to UTF-8 and write it to the buffer. More...
 
gcc_pure gcc_nonnull_all size_t LengthUTF8 (const char *p) noexcept
 Returns the number of characters in the string. More...
 

Function Documentation

◆ Latin1ToUTF8()

gcc_pure gcc_nonnull_all const char* Latin1ToUTF8 ( const char *  src,
char *  buffer,
size_t  buffer_size 
)
noexcept

Convert the specified string from ISO-8859-1 to UTF-8.

Returns
the UTF-8 version of the source string; may return #src if there are no non-ASCII characters; returns nullptr if the destination buffer is too small

◆ LengthUTF8()

gcc_pure gcc_nonnull_all size_t LengthUTF8 ( const char *  p)
noexcept

Returns the number of characters in the string.

This is different from strlen(), which counts the number of bytes.

◆ SequenceLengthUTF8() [1/2]

gcc_const size_t SequenceLengthUTF8 ( char  ch)
noexcept
Returns
the number of the sequence beginning with the given character, or 0 if the character is not a valid start byte

◆ SequenceLengthUTF8() [2/2]

gcc_pure size_t SequenceLengthUTF8 ( const char *  p)
noexcept
Returns
the number of the first sequence in the given string, or 0 if the sequence is malformed

◆ UnicodeToUTF8()

gcc_nonnull_all char* UnicodeToUTF8 ( unsigned  ch,
char *  buffer 
)
noexcept

Convert the specified Unicode character to UTF-8 and write it to the buffer.

buffer must have a length of at least 6!

Returns
a pointer to the buffer plus the added bytes(s)

◆ ValidateUTF8()

gcc_pure gcc_nonnull_all bool ValidateUTF8 ( const char *  p)
noexcept

Is this a valid UTF-8 string?