I'm trying to use ktor on a system that apparently...
# ktor
j
I'm trying to use ktor on a system that apparently does not have iso-8859-1 support installed. I'm not speaking HTTP where that charset is required, i'm just trying to use ktor-network to talk UTF-8 to a UDS. Has anyone encountered this before? Could charset initialization be made lazy?
Copy code
Caused by: kotlin.IllegalArgumentException: Failed to open iconv for charset ISO-8859-1 with error code 22
    at 0   example.kexe          0xea833b           kfun:kotlin.Throwable#<init>(kotlin.String?){} + 91
    at 1   example.kexe          0xea2ec3           kfun:kotlin.Exception#<init>(kotlin.String?){} + 83
    at 2   example.kexe          0xea3093           kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 83
    at 3   example.kexe          0xea3263           kfun:kotlin.IllegalArgumentException#<init>(kotlin.String?){} + 83
    at 4   example.kexe          0x14df68f          kfun:io.ktor.utils.io.charsets#checkErrors(kotlinx.cinterop.CPointer<out|kotlinx.cinterop.CPointed>?;kotlin.String){} + 639
    at 5   example.kexe          0x14df0c3          kfun:io.ktor.utils.io.charsets.CharsetIconv.<init>#internal + 515
    at 6   example.kexe          0x14ded53          kfun:io.ktor.utils.io.charsets.Charsets#<init>(){} + 275
    at 7   example.kexe          0x14dec03          kfun:io.ktor.utils.io.charsets.Charsets.$init_global#internal + 147
    at 8   example.kexe          0x15dc723          CallInitGlobalPossiblyLock + 487
    at 9   example.kexe          0x14dee87          kfun:io.ktor.utils.io.charsets.Charsets#<get-$instance>#static(){}io.ktor.utils.io.charsets.Charsets + 71
h
I think so, there are stored in the object for performance reasons to not recreate them: https://github.com/ktorio/ktor/blob/d5ae8e5641dea582fbe5ebb52577e7bdad2f5ad8/ktor-io/linux/src/CharsetLinux.kt#L14 But curios, what system does not have iso-8859-1/latin-1 preinstalled?
j
it's an embedded linux device that i don't control
i'm fine with them being cached, but they could be lazily initialized on first access
maybe i can just copy the utf-8 files and rename them iso-8859-1
it's quite possible i'm missing utf-8 as well and iso-8859-1 is just initializing first (alphabetically?)
i can't find any locale files
i have none of the binaries to query them, i have no env vars which would set it for the shell
utf-8 works. called into iconv_open myself to test
I filed https://youtrack.jetbrains.com/issue/KTOR-7016. We'll see what they say.
e
Hey @jw, thank you for sharing. I think we can make a fallback for this case
btw, could you tell me what implementation of iconv is used? (and if you can run
iconvconfig
)
j
I did a build locally where I changed iso 8859-1 and utf-16 to
by lazy
and it starts working, so just having a fallback or making it lazy would be enough
👍 1
There are no iconv binaries on the system that I can find, but I'll check again
Copy code
[root@rk3326_64:/]# iconv
/bin/sh: iconv: not found
[root@rk3326_64:/]# iconvconfig
/bin/sh: iconvconfig: not found
[root@rk3326_64:/]# locale
/bin/sh: locale: not found
[root@rk3326_64:/]# charsets
/bin/sh: charsets: not found
🤔 1
h
Does your device support the "charset" ITU-R M.1677-1? 💡
j
Wtf is that. I'll try when I get back to the computer
ah, morse code!
h
Yeah, for the light switch, right?
j
😶
it is, indeed
h
Then I am exited to see it next week
h
8859-1 is compatible with Win1252 if control codes are excluded.