Skip to content

Conversation

cknitt
Copy link
Member

@cknitt cknitt commented Sep 9, 2025

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt

The charCodeAt() method of String values returns an integer between 0 and 65535 ...

Copy link

pkg-pr-new bot commented Sep 9, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7864

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7864

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7864

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7864

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7864

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@7864

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7864

commit: b48531d

@cknitt cknitt requested a review from tsnobip September 9, 2025 16:47
@cknitt cknitt merged commit cfa4f7b into rescript-lang:master Sep 10, 2025
25 checks passed
@cknitt cknitt deleted the char-code-at branch September 10, 2025 06:20
@hackwaly
Copy link

I suspect that float is to cover this NaN case ""->String.charCodeAt(0)

@cknitt
Copy link
Member Author

cknitt commented Sep 10, 2025

You are right. I fear I have to roll this back. 😞

This is quite non-obvious though.

We can of course mention it in the docstring, but API-wise it would be much nicer if it returned option<int>. But that would need an extra wrapper.

@hackwaly
Copy link

Maybe we can have a charCodeAtUnsafe that returns int.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants