OSDN Git Service

Add function that calculates UTF-16 string length.
authorrelan <relan@users.noreply.github.com>
Sat, 28 Nov 2009 17:47:15 +0000 (17:47 +0000)
committerrelan <relan@users.noreply.github.com>
Mon, 24 Aug 2015 05:26:10 +0000 (08:26 +0300)
It will be used in future.

libexfat/exfat.h
libexfat/utf.c

index 5887a43..6670ae3 100644 (file)
@@ -117,6 +117,7 @@ int utf16_to_utf8(char* output, const le16_t* input, size_t outsize,
                size_t insize);
 int utf8_to_utf16(le16_t* output, const char* input, size_t outsize,
                size_t insize);
+size_t utf16_length(const le16_t* str);
 
 struct exfat_node* exfat_get_node(struct exfat_node* node);
 void exfat_put_node(struct exfat* ef, struct exfat_node* node);
index 6465661..8598d70 100644 (file)
@@ -211,3 +211,12 @@ int utf8_to_utf16(le16_t* output, const char* input, size_t outsize,
        *outp = cpu_to_le16(0);
        return 0;
 }
+
+size_t utf16_length(const le16_t* str)
+{
+       size_t i = 0;
+
+       while (le16_to_cpu(str[i]))
+               i++;
+       return i;
+}