haiku/headers/private/system/convertutf.h
John Scipione ebd3bcdb9b exfat: handle 4-byte UTF-16 surrogate pairs
... in filenames. Replace the existing Unicode conversion functions
with UTF conversion functions from js that he relicensed MIT for us.

Put the UTF conversion functions in a private but shared code location
so that they can be accessed throughout the kernel.

Right now we only provide functions to convert between UTF-8 and UTF-16.
At some point we should also add functions to convert between UTF-8 and
UTF-32 and UTF-16 and UTF-32 but these aren't needed by exfat.

Remove the old Unicode conversion functions from exfat as they assumed
UCS-2 characters and don't work with UTF-16 used by exfat.

Rename most variables with the term length with code unit where code units
are intended. The term length, when used, means length in bytes while code
units represent either a full 2-byte UTF-16 character or half a 4-byte
surrogate pair.
2014-04-11 18:46:03 -04:00

26 lines
581 B
C
Executable File

/*
* Copyright 2014 Jonathan Schleifer <js@webkeks.org>
* Copyright 2014 Haiku, Inc. All rights reserved.
*
* Distributed under the terms of the MIT License.
*
* Authors:
* Jonathan Schleifer, js@webkeks.org
* John Scipione, jscipione@gmail.com
*/
#ifndef CONVERT_UTF_H
#define CONVERT_UTF_H
#include <SupportDefs.h>
ssize_t utf16le_to_utf8(const uint16* source, size_t sourceCodeUnitCount,
char* target, size_t targetLength);
ssize_t utf16be_to_utf8(const uint16* source, size_t sourceCodeUnitCount,
char* target, size_t targetLength);
#endif // CONVERT_UTF_H