W3C home > Mailing lists > Public > www-validator-cvs@w3.org > October 2009

2006/unicorn/src/org/w3c/unicorn/output MailOutputModule.java,1.15,1.16

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 09 Oct 2009 06:47:21 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1Mw9G5-00077f-Vw@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/output
In directory hutz:/tmp/cvs-serv27249/src/org/w3c/unicorn/output

Modified Files:
	MailOutputModule.java 
Log Message:
UTF-8 charset when reading a template

Index: MailOutputModule.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/output/MailOutputModule.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- MailOutputModule.java	6 Oct 2009 10:03:57 -0000	1.15
+++ MailOutputModule.java	9 Oct 2009 06:47:19 -0000	1.16
@@ -4,7 +4,10 @@
 // Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.unicorn.output;
 
+import java.io.ByteArrayOutputStream;
 import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import java.text.SimpleDateFormat;
@@ -125,11 +128,17 @@
 				Multipart mp = new MimeMultipart("alternative");
 				for (OutputFormater outputFormater : mailOutputFormaters) {
 					MimeBodyPart bodyPart = new MimeBodyPart();
-					bodyPart.addHeader("Content-Type", outputFormater.getMimeType() + ", charset=UTF-8");
-					CharArrayWriter writer = new CharArrayWriter();
-					outputFormater.produceOutput(mapOfStringObject, writer);
-					writer.close();
-					bodyPart.setContent(writer.toString(), outputFormater.getMimeType());
+					
+					//CharArrayWriter writer = new CharArrayWriter();
+					ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+					OutputStreamWriter outputStreamWriter = new OutputStreamWriter(byteArrayOutputStream, "UTF-8");
+					
+					outputFormater.produceOutput(mapOfStringObject, outputStreamWriter);
+					outputStreamWriter.close();
+					byteArrayOutputStream.close();
+					bodyPart.setContent(byteArrayOutputStream.toString(), outputFormater.getMimeType());
+					bodyPart.setHeader("Content-Type", outputFormater.getMimeType() + "; charset=UTF-8");
+					bodyPart.setHeader("Content-Transfer-Encoding", "8bit");
 					mp.addBodyPart(bodyPart);
 				}
 				msg.setContent(mp);
@@ -151,6 +160,9 @@
 		} catch (UnsupportedEncodingException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
 		} 
 	}
 
Received on Friday, 9 October 2009 06:47:23 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:39 UTC