From 409011ade5c18135c4b3c1df71e72ba23f20c2a9 Mon Sep 17 00:00:00 2001 From: resver Date: Sat, 28 Nov 2009 17:47:15 +0000 Subject: [PATCH] Added function that calculates UTF-16 string length (will be used in future). git-svn-id: http://exfat.googlecode.com/svn/trunk@60 60bc1c72-a15a-11de-b98f-4500b42dc123 --- libexfat/exfat.h | 1 + libexfat/utf.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/libexfat/exfat.h b/libexfat/exfat.h index 5887a43..6670ae3 100644 --- a/libexfat/exfat.h +++ b/libexfat/exfat.h @@ -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); diff --git a/libexfat/utf.c b/libexfat/utf.c index 6465661..8598d70 100644 --- a/libexfat/utf.c +++ b/libexfat/utf.c @@ -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; +} -- 2.11.0