Changeset 1356

Show
Ignore:
Timestamp:
09/13/06 18:29:47 (2 years ago)
Author:
cstender
Message:

Added encoding support in organization hook (XMPM
062-encoding_in_organization_hook.patch)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/formats/vformats-xml/xml-kde.c

    r1176 r1356  
    256256} 
    257257 
     258static void add_value_decoded(VFormatAttribute *attr, const char *value, const char *encoding) 
     259{ 
     260        if (needs_charset((unsigned char*)value)) 
     261                if (!vformat_attribute_has_param (attr, "CHARSET")) 
     262                        vformat_attribute_add_param_with_value(attr, "CHARSET", "UTF-8"); 
     263         
     264        if (needs_encoding((unsigned char*)value, encoding)) { 
     265                if (!vformat_attribute_has_param (attr, "ENCODING")) 
     266                        vformat_attribute_add_param_with_value(attr, "ENCODING", encoding); 
     267                vformat_attribute_add_value_decoded(attr, value, strlen(value) + 1); 
     268        } else 
     269                vformat_attribute_add_value(attr, value); 
     270} 
     271 
    258272static void add_value(VFormatAttribute *attr, xmlNode *parent, const char *name, const char *encoding) 
    259273{ 
     
    261275        if (!tmp) 
    262276                return; 
    263          
    264         if (needs_charset((unsigned char*)tmp)) 
    265                 if (!vformat_attribute_has_param (attr, "CHARSET")) 
    266                         vformat_attribute_add_param_with_value(attr, "CHARSET", "UTF-8"); 
    267          
    268         if (needs_encoding((unsigned char*)tmp, encoding)) { 
    269                 if (!vformat_attribute_has_param (attr, "ENCODING")) 
    270                         vformat_attribute_add_param_with_value(attr, "ENCODING", encoding); 
    271                 vformat_attribute_add_value_decoded(attr, tmp, strlen(tmp) + 1); 
    272         } else 
    273                 vformat_attribute_add_value(attr, tmp); 
     277 
     278        add_value_decoded(attr, tmp, encoding);  
     279 
    274280        g_free(tmp); 
    275281} 
     
    378384                if (!strcmp((char*)root->name, "Name")) { 
    379385                        org = vformat_attribute_new(NULL, "ORG"); 
    380                         vformat_attribute_add_value(org, content); 
     386                        add_value_decoded(org, content, encoding); 
    381387                        vformat_add_attribute(vcard, org); 
    382388                }