diff options
author | Werner Koch <[email protected]> | 1998-11-03 19:38:58 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 1998-11-03 19:38:58 +0000 |
commit | b9dd2ebb2c08b457735f8acf997ff54965db91de (patch) | |
tree | 7d2408445104fa5135bd63b7e7bfc98d5a66688f /util/strgutil.c | |
parent | some random changes (diff) | |
download | gnupg-b9dd2ebb2c08b457735f8acf997ff54965db91de.tar.gz gnupg-b9dd2ebb2c08b457735f8acf997ff54965db91de.zip |
(Does not compile yet)
Diffstat (limited to '')
-rw-r--r-- | util/strgutil.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/util/strgutil.c b/util/strgutil.c index 809b0c3f2..217b64043 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -179,6 +179,52 @@ string_count_chr( const char *string, int c ) return count; } + +/**************** + * Convert string, which is in native encoding to UTF8 and return the + * new allocated UTF8 string. + * This code assumes that native is iso-8859-1. + */ +char * +native_to_utf8( const char *string ) +{ + const byte *s; + char *buffer; + byte *p; + size_t length=0; + + for(s=string; *s; s++ ) { + length++; + if( *s & 0x80 ) + length++; + } + buffer = m_alloc( length + 1 ); + for(p=buffer, s=string; *s; s++ ) { + if( *s & 0x80 ) { + *p++ = 0xc0 | ((*s >> 6) & 3); + *p++ = 0x80 | ( *s & 0x3f ); + } + else + *p++ = *s; + } + *p = 0; + return buffer; +} + + +/**************** + * Convert string, which is in UTF8 to native encoding. Replace + * illegal encodings by some "\xnn". + * This code assumes that native is iso-8859-1. + */ +char * +utf8_to_native( const char *string ) +{ + /* FIXME: Not yet done */ + return m_strdup(string); +} + + /********************************************* ********** missing string functions ********* *********************************************/ |