Changeset 281

Show
Ignore:
Timestamp:
08/28/08 08:22:07 PM (4 months ago)
Author:
octorian
Message:

Fix for character encoding problems (#99)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/LogicMail-1.0/LogicMail/src/org/logicprobe/LogicMail/message/MessagePartFactory.java

    r71 r281  
    3333 
    3434import java.io.IOException; 
     35import java.io.UnsupportedEncodingException; 
    3536import net.rim.device.api.system.EncodedImage; 
    3637import org.logicprobe.LogicMail.util.StringParser; 
     
    99100        } 
    100101        else if(encoding.equalsIgnoreCase("base64")) { 
     102            byte[] textBytes; 
    101103            try { 
    102                 byte[] textBytes = UtilProxy.getInstance().Base64Decode(data); 
    103                 data = new String(textBytes, StringParser.parseValidCharsetString(charset)); 
     104                textBytes = UtilProxy.getInstance().Base64Decode(data); 
    104105            } 
    105106            catch (IOException exp) { 
    106107                return createUnsupportedPart("text", mimeSubtype, data); 
     108            } 
     109             
     110            try { 
     111                data = new String(textBytes, charset.toUpperCase()); 
     112            } 
     113            catch (UnsupportedEncodingException exp) { 
     114                // If encoding type is bad, attempt with the default encoding 
     115                // so the user will at least see something. 
     116                data = new String(textBytes); 
    107117            } 
    108118        }