diff --git a/runtime/src/main/cpp/KString.cpp b/runtime/src/main/cpp/KString.cpp index fb6e2b2b059..3629ad93938 100644 --- a/runtime/src/main/cpp/KString.cpp +++ b/runtime/src/main/cpp/KString.cpp @@ -758,19 +758,27 @@ const char* byteArrayAsCString(KConstRef thiz, KInt start, KInt size) { } OBJ_GETTER(Kotlin_ByteArray_stringFromUtf8OrThrow, KConstRef thiz, KInt start, KInt size) { - const char* rawString = byteArrayAsCString(thiz, start, size); if (size == 0) { RETURN_RESULT_OF0(TheEmptyString); } - RETURN_RESULT_OF(utf8ToUtf16OrThrow, rawString, size); + const char* rawString = byteArrayAsCString(thiz, start, size); + KInt realSize = 0; + while (rawString[realSize] != 0 && realSize < size) { + realSize++; + } + RETURN_RESULT_OF(utf8ToUtf16OrThrow, rawString, realSize); } OBJ_GETTER(Kotlin_ByteArray_stringFromUtf8, KConstRef thiz, KInt start, KInt size) { - const char* rawString = byteArrayAsCString(thiz, start, size); if (size == 0) { RETURN_RESULT_OF0(TheEmptyString); } - RETURN_RESULT_OF(utf8ToUtf16, rawString, size); + const char* rawString = byteArrayAsCString(thiz, start, size); + KInt realSize = 0; + while (rawString[realSize] != 0 && realSize < size) { + realSize++; + } + RETURN_RESULT_OF(utf8ToUtf16, rawString, realSize); } OBJ_GETTER(Kotlin_String_toUtf8, KString thiz, KInt start, KInt size) { diff --git a/samples/settings.gradle b/samples/settings.gradle index 585fd56cf19..2764583d521 100644 --- a/samples/settings.gradle +++ b/samples/settings.gradle @@ -10,9 +10,8 @@ include ':nonBlockingEchoServer' include ':opengl' include ':socket' include ':tetris' -// ML samples have non-trivial deps, disable from here. -// include ':tensorflow' -// include ':torch' +include ':tensorflow' +include ':torch' // Android native activity build requires Android SDK. // So temporary switching off for now, as it breaks the build // of other samples if SDK is not present.