]> git.saurik.com Git - cycript.git/commitdiff
Worked around a stupid spec issue with iconv().
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 28 Oct 2009 04:52:34 +0000 (04:52 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 28 Oct 2009 04:52:34 +0000 (04:52 +0000)
Library.cpp

index 80a17f7510ed3c11733a4390ebe59e8301a329e2..aee85fa1497fe393a362574a7c6ed4225a2b6624 100644 (file)
@@ -140,6 +140,11 @@ static CYUTF16String CYCastUTF16String(JSStringRef value) {
     return CYUTF16String(JSStringGetCharactersPtr(value), JSStringGetLength(value));
 }
 
+template <typename Type_>
+_finline size_t iconv_(size_t (*iconv)(iconv_t, Type_, size_t *, char **, size_t *), iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) {
+    return iconv(cd, const_cast<Type_>(inbuf), inbytesleft, outbuf, outbytesleft);
+}
+
 static CYUTF8String CYPoolUTF8String(apr_pool_t *pool, JSContextRef context, JSStringRef value) {
     _assert(pool != NULL);
 
@@ -157,7 +162,7 @@ static CYUTF8String CYPoolUTF8String(apr_pool_t *pool, JSContextRef context, JSS
     CYUTF8String utf8(out, size);
 
     size = utf16.size * 2;
-    _syscall(iconv(conversion, const_cast<char **>(&in), &size, &out, &utf8.size));
+    _syscall(iconv_(&iconv, conversion, const_cast<char **>(&in), &size, &out, &utf8.size));
 
     *out = '\0';
     utf8.size = out - utf8.data;