aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java
diff options
context:
space:
mode:
authorYuichiro Hanada <yhanada@google.com>2013-10-16 00:08:02 +0900
committerYuichiro Hanada <yhanada@google.com>2013-10-16 00:30:45 +0900
commit1557de7aa47bdac707c06daa0a6cce3afda0de0f (patch)
treebe70f94801d1afe15fa633a4edeb44cb97470bde /java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java
parentb067be0e5f08eafd89eb0fd706ba564b898f317a (diff)
downloadlatinime-1557de7aa47bdac707c06daa0a6cce3afda0de0f.tar.gz
latinime-1557de7aa47bdac707c06daa0a6cce3afda0de0f.tar.xz
latinime-1557de7aa47bdac707c06daa0a6cce3afda0de0f.zip
Consolidate CharEncoding.writeString and BinaryDictIOUtils.writeString.
Change-Id: I6f990fd84e7f08fd1149198c33d8bbf1cac8e078
Diffstat (limited to 'java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java')
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java
index 216492b4d..8109321b6 100644
--- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java
+++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderUtils.java
@@ -225,20 +225,26 @@ public final class BinaryDictDecoderUtils {
*
* @param buffer the OutputStream to write to.
* @param word the string to write.
+ * @return the size written, in bytes.
*/
- static void writeString(final OutputStream buffer, final String word) throws IOException {
+ static int writeString(final OutputStream buffer, final String word) throws IOException {
final int length = word.length();
+ int written = 0;
for (int i = 0; i < length; i = word.offsetByCodePoints(i, 1)) {
final int codePoint = word.codePointAt(i);
- if (1 == getCharSize(codePoint)) {
+ final int charSize = getCharSize(codePoint);
+ if (1 == charSize) {
buffer.write((byte) codePoint);
} else {
buffer.write((byte) (0xFF & (codePoint >> 16)));
buffer.write((byte) (0xFF & (codePoint >> 8)));
buffer.write((byte) (0xFF & codePoint));
}
+ written += charSize;
}
buffer.write(FormatSpec.PTNODE_CHARACTERS_TERMINATOR);
+ written += FormatSpec.PTNODE_TERMINATOR_SIZE;
+ return written;
}
/**