From fce3238be069ec9e51806a054066c43e173d0d67 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Wed, 12 Jan 2011 23:21:33 +0000 Subject: Added UTF-8 to local encoding conversion functions. Just copies the string. svn path=/trunk/netsurf/; revision=11299 --- cocoa/utf8.m | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'cocoa') diff --git a/cocoa/utf8.m b/cocoa/utf8.m index ec75dfc91..2ec829888 100644 --- a/cocoa/utf8.m +++ b/cocoa/utf8.m @@ -19,18 +19,23 @@ #import #import "utils/utf8.h" -#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ ) utf8_convert_ret utf8_to_local_encoding(const char *string, size_t len, char **result) { - UNIMPL(); - return -1; + NSCParameterAssert( NULL != result ); + + char *newString = malloc( len + 1 ); + if (NULL == newString) return UTF8_CONVERT_NOMEM; + memcpy( newString, string, len ); + newString[len] = 0; + *result = newString; + return UTF8_CONVERT_OK; } utf8_convert_ret utf8_from_local_encoding(const char *string, size_t len, char **result) { - UNIMPL(); - return -1; + /* same function, local encoding = UTF-8 */ + return utf8_to_local_encoding( string, len, result ); } -- cgit v1.2.3