-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use convertToZeroTerminatedString on both wasm and js targets (#972)
This is supposed to be fix for #967 The idea is pass strings as (utf8) byte arrays directly through the border just like we do it on native
- Loading branch information
Showing
6 changed files
with
26 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
skiko/src/nativeJsMain/kotlin/org/jetbrains/skia/impl/Native.nativejs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.jetbrains.skia.impl | ||
|
||
/** | ||
* Converts String to zero-terminated utf-8 byte array. | ||
*/ | ||
internal fun convertToZeroTerminatedString(string: String): ByteArray { | ||
// C++ needs char* with zero byte at the end. So we need to copy array with an extra zero byte. | ||
|
||
val utf8 = string.encodeToByteArray() // encodeToByteArray encodes to utf8 | ||
// TODO Remove array copy, use `skString(data, length)` instead of `skString(data)` | ||
return utf8.copyOf(utf8.size + 1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters