#include "exfat.h"
#include <errno.h>
-static char* wchar_to_utf8(char* output, wchar_t wc, size_t outsize)
+static char* wchar_to_utf8(char* output, u32 wc, size_t outsize)
{
if (wc <= 0x7f)
{
return output;
}
-static const le16_t* utf16_to_wchar(const le16_t* input, wchar_t* wc,
+static const le16_t* utf16_to_wchar(const le16_t* input, u32* wc,
size_t insize)
{
if ((le16_to_cpu(input[0]) & 0xfc00) == 0xd800)
{
if (insize < 2 || (le16_to_cpu(input[1]) & 0xfc00) != 0xdc00)
return NULL;
- *wc = ((wchar_t) (le16_to_cpu(input[0]) & 0x3ff) << 10);
+ *wc = ((u32) (le16_to_cpu(input[0]) & 0x3ff) << 10);
*wc |= (le16_to_cpu(input[1]) & 0x3ff);
*wc += 0x10000;
return input + 2;
const le16_t* iend = input + insize;
char* optr = output;
const char* oend = output + outsize;
- wchar_t wc;
+ u32 wc;
while (iptr < iend)
{
return 0;
}
-static const char* utf8_to_wchar(const char* input, wchar_t* wc,
+static const char* utf8_to_wchar(const char* input, u32* wc,
size_t insize)
{
size_t size;
if ((input[0] & 0x80) == 0)
{
- *wc = (wchar_t) input[0];
+ *wc = (u32) input[0];
return input + 1;
}
else if ((input[0] & 0xe0) == 0xc0)
{
- *wc = ((wchar_t) input[0] & 0x1f) << 6;
+ *wc = ((u32) input[0] & 0x1f) << 6;
size = 2;
}
else if ((input[0] & 0xf0) == 0xe0)
{
- *wc = ((wchar_t) input[0] & 0x0f) << 12;
+ *wc = ((u32) input[0] & 0x0f) << 12;
size = 3;
}
else if ((input[0] & 0xf8) == 0xf0)
{
- *wc = ((wchar_t) input[0] & 0x07) << 18;
+ *wc = ((u32) input[0] & 0x07) << 18;
size = 4;
}
else if ((input[0] & 0xfc) == 0xf8)
{
- *wc = ((wchar_t) input[0] & 0x03) << 24;
+ *wc = ((u32) input[0] & 0x03) << 24;
size = 5;
}
else if ((input[0] & 0xfe) == 0xfc)
{
- *wc = ((wchar_t) input[0] & 0x01) << 30;
+ *wc = ((u32) input[0] & 0x01) << 30;
size = 6;
}
else
return input + size;
}
-static le16_t* wchar_to_utf16(le16_t* output, wchar_t wc, size_t outsize)
+static le16_t* wchar_to_utf16(le16_t* output, u32 wc, size_t outsize)
{
if (wc <= 0xffff) /* if character is from BMP */
{
const char* iend = input + insize;
le16_t* optr = output;
const le16_t* oend = output + outsize;
- wchar_t wc;
+ u32 wc;
while (iptr < iend)
{