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

Inconsistent printing of non-ASCII characters #606

Open
ksev opened this issue Nov 12, 2024 · 2 comments
Open

Inconsistent printing of non-ASCII characters #606

ksev opened this issue Nov 12, 2024 · 2 comments

Comments

@ksev
Copy link

ksev commented Nov 12, 2024

This code:

fun main() 
  "åäö".println
  Just("åäö").println
  ("åä","ö").println
  ["åäö"].println

Prints the following:

åäö
Just("\xE5\xE4\xF6")
("\xE5\xE4","\xF6")
["\xE5\xE4\xF6"]

I'm using Koka 3.1.2 on Fedora 41.

This does not seem like the intended behaviour?

@TimWhiting
Copy link
Collaborator

This is due to std/core/show.kk.

// Show a string as a string literal
pub noinline fun string/show( s : string ) : string
  "\"" ++ s.list.map(show-char).join ++ "\""

I think we should change this to

// Show a string as a string literal
pub noinline fun string/show( s : string ) : string
  "\"" ++ s ++ "\""
  
// Show a string as an escaped string literal
pub noinline fun string/show-raw( s : string ) : string
  "\"" ++ s.list.map(show-char).join ++ "\""

The name of the old functionality should maybe be show-raw, show-ascii, or something like that.

I don't think we should get rid of the surrounding quotes though.

@ksev
Copy link
Author

ksev commented Nov 12, 2024

Thanks, for some context i was working on some C bindings (https://github.com/ksev/koka-duckdb/) and could not for the life of me figure out why converting duckdb's strings to koka strings did not work for me, turns out they did i was just fooled by what was shown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants