Skip to content

Commit 2d3307b

Browse files
committed
Debug UTF-16 issue
1 parent ec1c431 commit 2d3307b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

extension/android/jni/jni_layer_llama.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
#include <cassert>
1010
#include <chrono>
11+
#include <codecvt>
1112
#include <iostream>
13+
#include <locale>
1214
#include <memory>
1315
#include <sstream>
1416
#include <string>
@@ -21,6 +23,7 @@
2123
#include <executorch/runtime/platform/log.h>
2224
#include <executorch/runtime/platform/platform.h>
2325
#include <executorch/runtime/platform/runtime.h>
26+
#include <android/log.h>
2427

2528
#if defined(ET_USE_THREADPOOL)
2629
#include <executorch/extension/threadpool/cpuinfo_utils.h>
@@ -45,7 +48,10 @@ class ExecuTorchLlamaCallbackJni
4548
static auto cls = ExecuTorchLlamaCallbackJni::javaClassStatic();
4649
static const auto method =
4750
cls->getMethod<void(facebook::jni::local_ref<jstring>)>("onResult");
48-
facebook::jni::local_ref<jstring> s = facebook::jni::make_jstring(result);
51+
static std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
52+
std::u16string result_u16 = converter.from_bytes(result);
53+
__android_log_print(ANDROID_LOG_ERROR, "ExecuTorchDBG", "U16:%s", result_u16.c_str());
54+
facebook::jni::local_ref<jstring> s = facebook::jni::make_jstring(result_u16);
4955
method(self(), s);
5056
}
5157

0 commit comments

Comments
 (0)