From 76802d328d9396ba592a9f6a955a2923f6ddf2d2 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Tue, 29 Nov 2011 05:21:26 +0000 Subject: [PATCH] Default the encoding of clipboard data to UTF-8. git-svn-id: http://google-refine.googlecode.com/svn/trunk@2390 7d457c2a-affb-35e4-300a-418c747d4874 --- .../com/google/refine/importing/ImportingUtilities.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main/src/com/google/refine/importing/ImportingUtilities.java b/main/src/com/google/refine/importing/ImportingUtilities.java index d9fc04c62..86918c564 100644 --- a/main/src/com/google/refine/importing/ImportingUtilities.java +++ b/main/src/com/google/refine/importing/ImportingUtilities.java @@ -224,11 +224,16 @@ public class ImportingUtilities { String name = fileItem.getFieldName().toLowerCase(); if (fileItem.isFormField()) { if (name.equals("clipboard")) { + String encoding = request.getCharacterEncoding(); + if (encoding == null) { + encoding = "UTF-8"; + } + File file = allocateFile(rawDataDir, "clipboard.txt"); JSONObject fileRecord = new JSONObject(); JSONUtilities.safePut(fileRecord, "origin", "clipboard"); - JSONUtilities.safePut(fileRecord, "declaredEncoding", request.getCharacterEncoding()); + JSONUtilities.safePut(fileRecord, "declaredEncoding", encoding); JSONUtilities.safePut(fileRecord, "declaredMimeType", (String) null); JSONUtilities.safePut(fileRecord, "format", "text"); JSONUtilities.safePut(fileRecord, "fileName", "(clipboard)");