View | Details | Raw Unified | Return to bug 45697
Collapse All | Expand All

(-)centericq/files/patch-msnhook.cc (-28 / +39 lines)
Lines 1-5 Link Here
1
--- src/hooks/msnhook.cc	Tue Nov 19 10:18:22 2002
1
--- src/hooks/msnhook.cc	Mon Nov 24 10:16:27 2002
2
+++ src/hooks/msnhook.cc	Tue Nov 19 10:18:35 2002
2
+++ src/hooks/msnhook.cc	Mon Nov 25 10:16:27 2002
3
@@ -30,6 +30,7 @@
3
@@ -30,6 +30,7 @@
4
 #include "eventmanager.h"
4
 #include "eventmanager.h"
5
 #include "centericq.h"
5
 #include "centericq.h"
Lines 39-45 Link Here
39
 	em.store(immessage(ic, imevent::incoming, text));
39
 	em.store(immessage(ic, imevent::incoming, text));
40
 
40
 
41
 	if(c)
41
 	if(c)
42
@@ -453,3 +456,121 @@
42
@@ -453,3 +456,132 @@
43
 	clist.get(contactroot)->playsound(imevent::email);
43
 	clist.get(contactroot)->playsound(imevent::email);
44
     }
44
     }
45
 }
45
 }
Lines 68-78 Link Here
68
+	return loc_charset;
68
+	return loc_charset;
69
+
69
+
70
+    lang = getenv("LANG");
70
+    lang = getenv("LANG");
71
+    ch = strrchr( lang, '.' ) + 1;
71
+    ch = strrchr( lang, '.' );
72
+    if (!ch)
72
+    if (!ch)
73
+	strcpy( loc_charset, DEFAULT_CHARSET );
73
+	strcpy( loc_charset, DEFAULT_CHARSET );
74
+    else {
74
+    else {
75
+	iconv_t pt;
75
+	iconv_t pt;
76
+	ch++;
76
+	strncpy( loc_charset, ch, sizeof(loc_charset) );
77
+	strncpy( loc_charset, ch, sizeof(loc_charset) );
77
+	/* try to open iconv handle using guessed charset */
78
+	/* try to open iconv handle using guessed charset */
78
+	if ( (pt = iconv_open( loc_charset, loc_charset )) == (iconv_t)(-1) )
79
+	if ( (pt = iconv_open( loc_charset, loc_charset )) == (iconv_t)(-1) )
Lines 96-107 Link Here
96
+    int ret;
97
+    int ret;
97
+
98
+
98
+    iconv_t handle = iconv_open( "utf-8", guess_current_locale_charset() );
99
+    iconv_t handle = iconv_open( "utf-8", guess_current_locale_charset() );
99
+    ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
100
+    if(((int) handle) != -1) {
101
+	ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
100
+    
102
+    
101
+    *outbuf = '\0';
103
+	*outbuf = '\0';
102
+    iconv_close( handle );
104
+	iconv_close( handle );
103
+
105
+	return outbuf_save;
104
+    return outbuf_save;
106
+    } else {
107
+	return (char *)inbuf;
108
+    };
105
+}
109
+}
106
+ 
110
+ 
107
+std::string StrToUtf8( const std::string &instr )
111
+std::string StrToUtf8( const std::string &instr )
Lines 114-126 Link Here
114
+    int ret;
118
+    int ret;
115
+
119
+
116
+    iconv_t handle = iconv_open( "utf-8", guess_current_locale_charset() );
120
+    iconv_t handle = iconv_open( "utf-8", guess_current_locale_charset() );
117
+    ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
121
+    if(((int) handle) != -1) {
122
+	ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
118
+    
123
+    
119
+    *outbuf = '\0';
124
+	*outbuf = '\0';
120
+    iconv_close( handle );
125
+	iconv_close( handle );
121
+
126
+
122
+    std::string return_me = outbuf_save;
127
+	std::string return_me = outbuf_save;
123
+    return return_me;
128
+	return return_me;
129
+    } else {
130
+	return instr;
131
+    };
124
+}
132
+}
125
+ 
133
+ 
126
+char *Utf8ToStr( const char *inbuf )
134
+char *Utf8ToStr( const char *inbuf )
Lines 132-144 Link Here
132
+    int ret;
140
+    int ret;
133
+
141
+
134
+    iconv_t handle = iconv_open( guess_current_locale_charset(), "utf-8" );
142
+    iconv_t handle = iconv_open( guess_current_locale_charset(), "utf-8" );
135
+
143
+    if(((int) handle) != -1) {
136
+    ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
144
+	ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
137
+    
145
+	*outbuf = '\0';
138
+    *outbuf = '\0';
146
+	iconv_close( handle );
139
+    iconv_close( handle );
147
+	return outbuf_save;
140
+
148
+    } else {
141
+    return outbuf_save;
149
+	return (char *)inbuf;
150
+    };
142
+}
151
+}
143
+
152
+
144
+std::string Utf8ToStr( const std::string &instr )
153
+std::string Utf8ToStr( const std::string &instr )
Lines 152-163 Link Here
152
+
161
+
153
+    iconv_t handle = iconv_open( guess_current_locale_charset(), "utf-8" );
162
+    iconv_t handle = iconv_open( guess_current_locale_charset(), "utf-8" );
154
+
163
+
155
+    ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
164
+    if(((int) handle) != -1) {
156
+
165
+	ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength );
157
+    *outbuf = '\0';
166
+	*outbuf = '\0';
158
+    iconv_close( handle );
167
+	iconv_close( handle );
159
+
168
+	std::string return_me = outbuf_save;
160
+    std::string return_me = outbuf_save;
169
+	return return_me;
161
+    return return_me;
170
+    } else {
171
+	return instr;
172
+    };
162
+}
173
+}
163
+#endif /* HAVE_ICONV_H */
174
+#endif /* HAVE_ICONV_H */

Return to bug 45697