Char encoding error
chabapok opened this issue · 2 comments
chabapok commented
If we try encode Char, it encoded with double quotes. If we try to decode, it fails. Decoder wants single-quoted chars:
@Serializable
data class Foo(val foo: Char= 'x')
fun main(){
val s = Toml().encodeToString(Foo('f'))
println(s) // foo = "f"
// decode exception
val config = Toml().decodeFromString<Foo>(s)
// single-quoted decoded ok
Toml().decodeFromString<Foo>("doo='f'")
}
orchestr7 commented
Thanks for this report!
@chabapok, As per the TOML specification, there is no predefined Char type. However, we've introduced the concept in our TOML implementation to align more closely with Kotlin's syntax. So we are expecting Chars to have single quote on the decoding.
Probably we need to make it more convenient and do encoding and decoding similar.
Will fix it, thanks!