make sure we use utf8 charset

This commit is contained in:
Shay Banon 2012-07-19 11:29:27 -07:00
parent cc2a6babda
commit 153c0de636
1 changed files with 2 additions and 1 deletions

View File

@ -73,11 +73,12 @@ public class StringAndBytesText implements Text {
@Override
public String string() {
// TODO: we can optimize the conversion based on the bytes reference API similar to UnicodeUtil
if (text == null) {
if (!bytes.hasArray()) {
bytes = bytes.toBytesArray();
}
text = new String(bytes.array(), bytes.arrayOffset(), bytes.length());
text = new String(bytes.array(), bytes.arrayOffset(), bytes.length(), Charsets.UTF_8);
}
return text;
}