comparison src/libpst.c @ 193:cf3df962f1e5 stable-0-6-37

prep for fedora build
author Carl Byington <carl@five-ten-sg.com>
date Fri, 17 Apr 2009 12:51:59 -0700
parents 4b498fd68464
children 320cfcba8058
comparison
equal deleted inserted replaced
192:774b2e77eb50 193:cf3df962f1e5
4189 * 4189 *
4190 * @param cp the code page integer used in the pst file 4190 * @param cp the code page integer used in the pst file
4191 * @return pointer to a static buffer holding the string representation of the 4191 * @return pointer to a static buffer holding the string representation of the
4192 * equivalent iconv character set 4192 * equivalent iconv character set
4193 */ 4193 */
4194 const char* codepage(int cp) { 4194 static const char* codepage(int cp);
4195 static const char* codepage(int cp) {
4195 static char buffer[20]; 4196 static char buffer[20];
4196 switch (cp) { 4197 switch (cp) {
4197 case 932 : return "iso-2022-jp"; 4198 case 932 : return "iso-2022-jp";
4198 case 936 : return "gb2313"; 4199 case 936 : return "gb2313";
4199 case 950 : return "big5"; 4200 case 950 : return "big5";
4233 /** Get the default character set for this item. This is used to find 4234 /** Get the default character set for this item. This is used to find
4234 * the charset for pst_string elements that are not already in utf8 encoding. 4235 * the charset for pst_string elements that are not already in utf8 encoding.
4235 * @param item pointer to the mapi item of interest 4236 * @param item pointer to the mapi item of interest
4236 * @return default character set as a string useable by iconv() 4237 * @return default character set as a string useable by iconv()
4237 */ 4238 */
4238 const char* pst_default_charset(pst_item *item) 4239 const char* pst_default_charset(pst_item *item) {
4239 {
4240 return (item->body_charset.str) ? item->body_charset.str : 4240 return (item->body_charset.str) ? item->body_charset.str :
4241 (item->message_codepage) ? codepage(item->message_codepage) : 4241 (item->message_codepage) ? codepage(item->message_codepage) :
4242 (item->internet_cpid) ? codepage(item->internet_cpid) : 4242 (item->internet_cpid) ? codepage(item->internet_cpid) :
4243 "utf-8"; 4243 "utf-8";
4244 } 4244 }
4247 /** Convert str to utf8 if possible; null strings are preserved. 4247 /** Convert str to utf8 if possible; null strings are preserved.
4248 * 4248 *
4249 * @param item pointer to the containing mapi item 4249 * @param item pointer to the containing mapi item
4250 * @param str pointer to the mapi string of interest 4250 * @param str pointer to the mapi string of interest
4251 */ 4251 */
4252 void pst_convert_utf8_null(pst_item *item, pst_string *str) 4252 void pst_convert_utf8_null(pst_item *item, pst_string *str) {
4253 {
4254 if (!str->str) return; 4253 if (!str->str) return;
4255 pst_convert_utf8(item, str); 4254 pst_convert_utf8(item, str);
4256 } 4255 }
4257 4256
4258 4257
4259 /** Convert str to utf8 if possible; null strings are converted into empty strings. 4258 /** Convert str to utf8 if possible; null strings are converted into empty strings.
4260 * 4259 *
4261 * @param item pointer to the containing mapi item 4260 * @param item pointer to the containing mapi item
4262 * @param str pointer to the mapi string of interest 4261 * @param str pointer to the mapi string of interest
4263 */ 4262 */
4264 void pst_convert_utf8(pst_item *item, pst_string *str) 4263 void pst_convert_utf8(pst_item *item, pst_string *str) {
4265 {
4266 if (str->is_utf8) return; 4264 if (str->is_utf8) return;
4267 if (!str->str) { 4265 if (!str->str) {
4268 str->str = strdup(""); 4266 str->str = strdup("");
4269 return; 4267 return;
4270 } 4268 }