Project

General

Profile

« Previous | Next » 

Revision 5792

use the detected document encoding when getting the outputstream writer from the response
http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2495

View differences:

src/edu/ucsb/nceas/metacat/MetacatHandler.java
25 25
package edu.ucsb.nceas.metacat;
26 26

  
27 27
import java.io.BufferedInputStream;
28
import java.io.ByteArrayInputStream;
28 29
import java.io.File;
29 30
import java.io.FileInputStream;
30 31
import java.io.IOException;
......
1085 1086
                        response.setContentType("text/html"); //MIME type
1086 1087
                    }
1087 1088
                    
1088
                    // TODO: detect actual encoding
1089
                    Writer w = new OutputStreamWriter(out, response.getCharacterEncoding());
1090
                    
1089
                    // detect actual encoding
1090
                    String docString = doc.toString(user, groups, withInlineData);
1091
                    XmlStreamReader xsr = new XmlStreamReader(new ByteArrayInputStream(doc.getBytes()));
1092
        			String encoding = xsr.getEncoding();
1093
                    Writer w = null;
1094
        			if (encoding != null) {
1095
        				w = new OutputStreamWriter(out, encoding);
1096
        			} else {
1097
                        w = new OutputStreamWriter(out);
1098
        			}
1099

  
1091 1100
                    // Look up the document type
1092 1101
                    String doctype = doc.getDoctype();
1093 1102
                    // Transform the document to the new doctype
1094 1103
                    DBTransform dbt = new DBTransform();
1095 1104
                    dbt.transformXMLDocument(
1096
                    		doc.toString(user, groups, withInlineData), 
1105
                    		docString, 
1097 1106
                    		doctype, "-//W3C//HTML//EN",
1098 1107
                            qformat, 
1099 1108
                            w, 

Also available in: Unified diff