Hi friends! I have a test that checks whether a `....
# codereview
p
Hi friends! I have a test that checks whether a
.properties
file correctly loads entries as UTF-8 — once the
reader
is using the correct charset,
Properties
works as expected. Consider this excerpt:
Copy code
val expected = mapOf(
    "italian" to "anatra",
    "russian" to "утка",
    "chinese" to "鸭子",
    "japanese" to "アヒル",
    "korean" to "오리",
    "arabic" to "بطه",
    "hindi" to "बत्तख",
    ...
)
I was wondering if I should hardcode these strings into the Kotlin file, specially that I have RTL ones in there. Is this okay or there is a better way? Any suggestions are welcome! Thanks!
e
there's no good way to write non-BMP characters (most of CJK, emoji, etc.) by character code in Kotlin currently https://youtrack.jetbrains.com/issue/KT-36872/Unicode-code-point-literals
for now, if it's all readable characters (no LTR/RTL markers, ZWJ or other control or special space chars), IMO the best choice is to just write them directly in the Kotlin source file (which is interpreted as UTF-8). you may get warnings in your IDE or editor due to the use of mixed directionality but that's just how it is
✔️ 1
gratitude thank you 1
p
Thanks so much, @ephemient! Will do that. 😉
l
You can always encode them as surrogate pairs using
"\uXXXX"
syntax. That's what I do.
e
you can but it's less clear than if it were possible to
\u{XXXXX}
and IMO it's less clear than having the literal character there because the surrogate representation isn't how we think of the character in any other situation