gpt: return size of created strings in to_utf8/to_ucs2.
This commit is contained in:
parent
32624578b6
commit
222c84407a
@ -34,9 +34,10 @@ put_utf8_byte(char*& to, size_t& left, char c)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
void
|
size_t
|
||||||
to_utf8(const uint16* from, size_t maxFromLength, char* to, size_t toSize)
|
to_utf8(const uint16* from, size_t maxFromLength, char* to, size_t toSize)
|
||||||
{
|
{
|
||||||
|
const char* start = to;
|
||||||
for (uint32 i = 0; i < maxFromLength; i++) {
|
for (uint32 i = 0; i < maxFromLength; i++) {
|
||||||
// Decoding UTF-16LE
|
// Decoding UTF-16LE
|
||||||
uint32 c = 0;
|
uint32 c = 0;
|
||||||
@ -82,12 +83,14 @@ to_utf8(const uint16* from, size_t maxFromLength, char* to, size_t toSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (toSize > 0)
|
if (toSize > 0)
|
||||||
*to = '\0';
|
*to++ = '\0';
|
||||||
|
|
||||||
|
return to - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef _BOOT_MODE
|
#ifndef _BOOT_MODE
|
||||||
void
|
size_t
|
||||||
to_ucs2(const char* from, size_t fromLength, uint16* to, size_t maxToLength)
|
to_ucs2(const char* from, size_t fromLength, uint16* to, size_t maxToLength)
|
||||||
{
|
{
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
@ -110,7 +113,9 @@ to_ucs2(const char* from, size_t fromLength, uint16* to, size_t maxToLength)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (index < maxToLength)
|
if (index < maxToLength)
|
||||||
to[index] = '\0';
|
to[index++] = '\0';
|
||||||
|
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
#endif // !_BOOT_MODE
|
#endif // !_BOOT_MODE
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@ struct static_guid;
|
|||||||
extern const guid_t kEmptyGUID;
|
extern const guid_t kEmptyGUID;
|
||||||
|
|
||||||
|
|
||||||
void to_utf8(const uint16* from, size_t maxFromLength, char* to, size_t toSize);
|
size_t to_utf8(const uint16* from, size_t maxFromLength, char* to, size_t toSize);
|
||||||
const char* get_partition_type(const guid_t& guid);
|
const char* get_partition_type(const guid_t& guid);
|
||||||
|
|
||||||
#ifndef _BOOT_MODE
|
#ifndef _BOOT_MODE
|
||||||
void to_ucs2(const char* from, size_t fromLength, uint16* to,
|
size_t to_ucs2(const char* from, size_t fromLength, uint16* to,
|
||||||
size_t maxToLength);
|
size_t maxToLength);
|
||||||
bool get_guid_for_partition_type(const char* type, guid_t& guid);
|
bool get_guid_for_partition_type(const char* type, guid_t& guid);
|
||||||
#endif // !_BOOT_MODE
|
#endif // !_BOOT_MODE
|
||||||
|
Loading…
Reference in New Issue
Block a user