From 7c67adea66c9e0cedae4b2045b0a0468fd26f74d Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 20 Apr 2001 12:21:23 +0000 Subject: Add UTF-8 charset --- NEWS | 2 ++ VERSION | 2 +- doc/ChangeLog | 4 ++++ doc/gpg.sgml | 7 ++++++- g10/ChangeLog | 6 +++++- g10/options.skel | 17 ++++++++++++++--- util/ChangeLog | 7 +++++++ util/strgutil.c | 22 ++++++++++++++++++++-- 8 files changed, 59 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 17df5e6e7..658e4a93e 100644 --- a/NEWS +++ b/NEWS @@ -38,6 +38,8 @@ was just wrong, so you might notice bad signature in some very big files. It may be wise to keep an old copy of GnuPG around. + * New --charset=utf-8 to bypass all internal translations. + Noteworthy changes in version 1.0.4 (2000-10-17) ------------------------------------------------ diff --git a/VERSION b/VERSION index 770d18542..e7a32df5c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.4h +1.0.4i diff --git a/doc/ChangeLog b/doc/ChangeLog index 32c19c240..59e43d8aa 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2001-04-20 Werner Koch + + * gpg.sgml: Add new --charset UTF-8. + 2001-04-19 Werner Koch * faq.raw: Add a note about dates displayed as ????-??-??. diff --git a/doc/gpg.sgml b/doc/gpg.sgml index 0ddaca95c..f343bc07b 100644 --- a/doc/gpg.sgml +++ b/doc/gpg.sgml @@ -367,7 +367,8 @@ assigned owner trust and the second is the calculated trust value. Letters are used for the values: -No ownertrust assigned / not yet calculated. - eTrust calculation has failed. + eTrust +calculation has failed; probably due to an expired key. qNot enough information for calculation. nNever trust this key. mMarginally trusted. @@ -846,6 +847,10 @@ Valid values for &ParmName; are: koi8-rThe usual Russian set (rfc1489). + +utf-8Bypass all translations and assume +that the OS uses native UTF-8 encoding. + diff --git a/g10/ChangeLog b/g10/ChangeLog index d08090e44..b93e0b3ca 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,6 +1,10 @@ +2001-04-20 Werner Koch + + * options.skel: Add some more comments. + 2001-04-19 Werner Koch - * keyid.c (mk_datestr): New. Handles negative times. we must do + * keyid.c (mk_datestr): New. Handles negative times. We must do this because Windoze segvs on negative times passed to gmtime(). Changed all datestr_from function to use this one. diff --git a/g10/options.skel b/g10/options.skel index f2a117e23..ad47c9fa6 100644 --- a/g10/options.skel +++ b/g10/options.skel @@ -31,6 +31,18 @@ $Id$ #default-key 621CC013 +# GnuPG ultimately trusts all keys in the secret keyring. If you do +# not have all your secret keys online available you should use this +# option to tell GnuPG about ultimately trusted keys. +# You have to give the long keyID here which can be obtained by using +# the --list-key command along with the option --with-colons; you will +# get a line similiar to this one: +# pub:u:1024:17:5DE249965B0358A2:1999-03-15:2006-02-04:59:f: +# the 5th field is what you want. + +#trusted-key 12345678ABCDEF01 + + # If you do not pass a recipient to gpg, it will ask for one. # Using this option you can encrypt to a default key. key validation # will not be done in this case. @@ -55,8 +67,8 @@ escape-from-lines # If you do not use the Latin-1 (ISO-8859-1) charset, you should # tell GnuPG which is the native character set. Please check -# the man page for supported character sets. -#charset koi8-r +# the man page for supported character sets. +#charset utf-8 # You may define aliases like this: @@ -92,4 +104,3 @@ lock-once # this option is set. honor-http-proxy - diff --git a/util/ChangeLog b/util/ChangeLog index 1530f07b3..63d932d77 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,10 @@ +2001-04-20 Werner Koch + + * strgutil.c (set_native_charset): Allow utf-8 by introducing the + new no_translation variable. + (native_to_utf8): Handle no_translation. + (utf8_to_native): Ditto. + 2001-04-19 Werner Koch * miscutil.c (asctimestamp): Handle negative times. We must do diff --git a/util/strgutil.c b/util/strgutil.c index f65a16167..c1531bbe3 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -67,7 +67,7 @@ static ushort latin2_unicode[128] = { static const char *active_charset_name = "iso-8859-1"; static ushort *active_charset = NULL; - +static int no_translation = 0; void free_strlist( STRLIST sl ) @@ -327,16 +327,24 @@ set_native_charset( const char *newset ) { if( !stricmp( newset, "iso-8859-1" ) ) { active_charset_name = "iso-8859-1"; + no_translation = 0; active_charset = NULL; } else if( !stricmp( newset, "iso-8859-2" ) ) { active_charset_name = "iso-8859-2"; + no_translation = 0; active_charset = latin2_unicode; } else if( !stricmp( newset, "koi8-r" ) ) { active_charset_name = "koi8-r"; + no_translation = 0; active_charset = koi8_unicode; } + else if( !stricmp (newset, "utf8" ) || !stricmp(newset, "utf-8") ) { + active_charset_name = "utf-8"; + no_translation = 1; + active_charset = NULL; + } else return G10ERR_GENERAL; return 0; @@ -360,7 +368,10 @@ native_to_utf8( const char *string ) byte *p; size_t length=0; - if( active_charset ) { + if (no_translation) { + buffer = m_strdup (string); + } + else if( active_charset ) { for(s=string; *s; s++ ) { length++; if( *s & 0x80 ) @@ -424,6 +435,13 @@ utf8_to_native( const char *string, size_t length ) size_t slen; int resync = 0; + if (no_translation) { + buffer = m_alloc (length+1); + memcpy (buffer, string, length); + buffer[length] = 0; /* make sure it is a string */ + return buffer; + } + /* 1. pass (p==NULL): count the extended utf-8 characters */ /* 2. pass (p!=NULL): create string */ for( ;; ) { -- cgit v1.2.3