Mercurial > pidgin
annotate src/xmlnode.h @ 7724:613b20c69d2c
[gaim-migrate @ 8369]
this didn't cause me any problems yesterday, and it compiles, and bug fixing is a good thing.
"Some month ago I introduced translatable texts for "gaim --help" and
"gaim-remote --help".
Unfortunately the output of the translated text is often unreadable.
The problem is, that Gaim's *.po files have the UTF-8 locale (because
this is the default charset for GTK+ 2.0). But the users may have
configured other locales. For instance my SuSE Linux 9.0 system is
configured with LANG=de_DE@euro. "euro" is ISO-8859-1 (Western
character set, 8 Bit, with the Euro currency symbol). Lots of UTF-8
characters are unreadable if they are displayed in a 8 Bit charset
without conversion. Only the 7 Bit chars are displayed right.
There are two possible solutions:
1) Make the console texts untranslatable. This isn't very clever.
2) Convert the texts from UTF-8 to user's locale.
I choose the second solution.
The conversion cannot be made during the translation, because gettext
does not allow a mix of different character sets in one po-file.
My patch converts the console strings from UTF-8 to users locale.
Normally this works right, because most users have a locale which is
compatible with their language.
The case where a user uses a language (for instance German:
LANG=de_DE) with an incompatible character set (for instance the 7Bit
charset LC_CTYPE=C) is also handled. The user then sees a warning and
the original UTF-8 message.
At first I tried to make a new UTF-8 function in src/util.c. But the
function is needed 5 times in src/gaim-remote.c and 2 times in
src/main.c. gaim-remote is not linked against util.o. Also there are a
lot of dependencies from util.o to other files, so I will introduce a
lot of trouble to link gaim-remote against util.o.
So I only wrote a function in src/gaim-remote.c and used the UTF-8
conversion inline in src/main.c." --Bjoern Voigt
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Wed, 03 Dec 2003 13:21:55 +0000 |
| parents | 9008b5be4275 |
| children | fa6395637e2c |
| rev | line source |
|---|---|
| 7131 | 1 /** |
| 2 * @file xmlnode.h XML DOM functions | |
| 3 * | |
| 4 * gaim | |
| 5 * | |
| 6 * Copyright (C) 2003 Nathan Walp <faceprint@faceprint.com> | |
| 7 * | |
| 8 * This program is free software; you can redistribute it and/or modify | |
| 9 * it under the terms of the GNU General Public License as published by | |
| 10 * the Free Software Foundation; either version 2 of the License, or | |
| 11 * (at your option) any later version. | |
| 12 * | |
| 13 * This program is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 * GNU General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU General Public License | |
| 19 * along with this program; if not, write to the Free Software | |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 */ | |
| 22 #ifndef _GAIM_XMLNODE_H_ | |
| 23 #define _GAIM_XMLNODE_H_ | |
| 24 | |
| 25 typedef enum _NodeType | |
| 26 { | |
| 27 NODE_TYPE_TAG, | |
| 28 NODE_TYPE_ATTRIB, | |
| 29 NODE_TYPE_DATA | |
| 30 } NodeType; | |
| 31 | |
| 32 typedef struct _xmlnode | |
| 33 { | |
| 34 char *name; | |
| 35 NodeType type; | |
| 36 char *data; | |
| 37 size_t data_sz; | |
| 38 struct _xmlnode *parent; | |
| 39 struct _xmlnode *child; | |
| 40 struct _xmlnode *next; | |
| 41 } xmlnode; | |
| 42 | |
| 43 xmlnode *xmlnode_new(const char *name); | |
| 44 xmlnode *xmlnode_new_child(xmlnode *parent, const char *name); | |
| 45 void xmlnode_insert_child(xmlnode *parent, xmlnode *child); | |
| 46 xmlnode *xmlnode_get_child(xmlnode *parent, const char *name); | |
| 47 void xmlnode_insert_data(xmlnode *parent, const char *data, size_t size); | |
| 48 char *xmlnode_get_data(xmlnode *node); | |
| 49 void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value); | |
| 50 const char *xmlnode_get_attrib(xmlnode *node, const char *attr); | |
| 51 void xmlnode_remove_attrib(xmlnode *node, const char *attr); | |
| 7642 | 52 char *xmlnode_to_str(xmlnode *node, int *len); |
| 7131 | 53 xmlnode *xmlnode_from_str(const char *str, size_t size); |
| 54 | |
| 55 void xmlnode_free(xmlnode *node); | |
| 56 | |
| 57 #endif /* _GAIM_XMLNODE_H_ */ |
