SdFat
Functions
FsUtf Namespace Reference

Functions

char * cpToMb (uint32_t cp, char *str, char *end)
 
uint16_t highSurrogate (uint32_t cp)
 
bool isHighSurrogate (uint16_t c)
 
bool isLowSurrogate (uint16_t c)
 
bool isSurrogate (uint16_t c)
 
bool isValidCp (uint32_t cp)
 
uint16_t lowSurrogate (uint32_t cp)
 
const char * mbToCp (const char *str, const char *end, uint32_t *rtn)
 
const char * mbToU16 (const char *str, const char *end, uint16_t *hs, uint16_t *ls)
 
uint32_t u16ToCp (uint16_t hs, uint16_t ls)
 

Detailed Description

Copyright (c) 2011-2021 Bill Greiman This file is part of the SdFat library for SD memory cards.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Function Documentation

◆ cpToMb()

char * FsUtf::cpToMb ( uint32_t  cp,
char *  str,
char *  end 
)

Encodes a 32 bit code point as a UTF-8 sequence.

Parameters
[in]cpcode point to encode.
[out]strlocation for UTF-8 sequence.
[in]endlocation following last character of str.
Returns
location one beyond last encoded character.

◆ highSurrogate()

uint16_t FsUtf::highSurrogate ( uint32_t  cp)
inline

High surrogate for a code point.

Parameters
cpcode point.
Returns
high surrogate.

◆ isHighSurrogate()

bool FsUtf::isHighSurrogate ( uint16_t  c)
inline

Check for UTF-16 high surrogate.

Parameters
[in]cUTF-16 unit..
Returns
true if c is a high surrogate else false.

◆ isLowSurrogate()

bool FsUtf::isLowSurrogate ( uint16_t  c)
inline

Check for UTF-16 low surrogate.

Parameters
[in]cUTF-16 unit..
Returns
true if c is a low surrogate else false.

◆ isSurrogate()

bool FsUtf::isSurrogate ( uint16_t  c)
inline

Check for UTF-16 surrogate.

Parameters
[in]cUTF-16 unit.
Returns
true if c is a surrogate else false.

◆ isValidCp()

bool FsUtf::isValidCp ( uint32_t  cp)
inline

Check for a valid code point.

Parameters
[in]cpcode point.
Returns
true if valid else false.

◆ lowSurrogate()

uint16_t FsUtf::lowSurrogate ( uint32_t  cp)
inline

Low surrogate for a code point.

Parameters
cpcode point.
Returns
low surrogate.

◆ mbToCp()

const char * FsUtf::mbToCp ( const char *  str,
const char *  end,
uint32_t *  rtn 
)

Get next code point from a UTF-8 sequence.

Parameters
[in]strlocation for UTF-8 sequence.
[in]endlocation following last character of str. May be nullptr if str is zero terminated.
[out]rtnlocation for the code point.
Returns
location of next UTF-8 character in str of nullptr for error.

◆ mbToU16()

const char * FsUtf::mbToU16 ( const char *  str,
const char *  end,
uint16_t *  hs,
uint16_t *  ls 
)

Get next code point from a UTF-8 sequence as UTF-16.

Parameters
[in]strlocation for UTF-8 sequence.
[in]endlocation following last character of str.
[out]hslocation for the code point or high surrogate.
[out]lslocation for zero or high surrogate.
Returns
location of next UTF-8 character in str of nullptr for error.

◆ u16ToCp()

uint32_t FsUtf::u16ToCp ( uint16_t  hs,
uint16_t  ls 
)
inline

Convert UFT-16 surrogate pair to code point.

Parameters
[in]hshigh surrogate.
[in]lslow surrogate.
Returns
code point.