summaryrefslogtreecommitdiff
path: root/cocoa/utf8.m
diff options
context:
space:
mode:
authorSven Weidauer <sven.weidauer@gmail.com>2011-01-12 23:21:33 +0000
committerSven Weidauer <sven.weidauer@gmail.com>2011-01-12 23:21:33 +0000
commitfce3238be069ec9e51806a054066c43e173d0d67 (patch)
treeaaca1509fa942692580dc22701085dc95049bf1a /cocoa/utf8.m
parent23770014c0915191fe88e11fd72d37a69c1ed2a5 (diff)
downloadnetsurf-fce3238be069ec9e51806a054066c43e173d0d67.tar.gz
netsurf-fce3238be069ec9e51806a054066c43e173d0d67.tar.bz2
Added UTF-8 to local encoding conversion functions. Just copies the string.
svn path=/trunk/netsurf/; revision=11299
Diffstat (limited to 'cocoa/utf8.m')
-rw-r--r--cocoa/utf8.m15
1 files changed, 10 insertions, 5 deletions
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 <Cocoa/Cocoa.h>
#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 );
}