Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Char encoding error #260

Closed
chabapok opened this issue Mar 8, 2024 · 2 comments · Fixed by #261
Closed

Char encoding error #260

chabapok opened this issue Mar 8, 2024 · 2 comments · Fixed by #261
Assignees
Labels
bug Something isn't working

Comments

@chabapok
Copy link

chabapok commented Mar 8, 2024

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
Copy link
Owner

orchestr7 commented Mar 8, 2024

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!

@orchestr7 orchestr7 self-assigned this Mar 8, 2024
@orchestr7 orchestr7 added the bug Something isn't working label Mar 8, 2024
@orchestr7 orchestr7 linked a pull request Mar 8, 2024 that will close this issue
@orchestr7
Copy link
Owner

fixed in #261

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants