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

added quickjs example #396

Merged
merged 2 commits into from
Apr 12, 2021
Merged

Conversation

coderofsalvation
Copy link
Contributor

No description provided.

@asergeyev
Copy link
Collaborator

I'm bit confused because bigger part of this code UTF conversion.... Anyone experienced in qjs can review/comment?

@coderofsalvation
Copy link
Contributor Author

coderofsalvation commented Apr 1, 2021

quickjs's stdin is internally streaming chunked integers. To eventually send it out, a conversion to a string is needed. Simply converting integers to chars would not restore special (utf8) characters, hence the utf8 code.

@ctn-malone
Copy link

ctn-malone commented Apr 7, 2021

While the code in this PR is the way to go to convert bytes array to utf8, if you use std.in.getline() instead of std.in.getByte(), there should be no need for any conversion

import * as std from 'std';

let line;
while ((line = std.in.getline()) != null) {
    console.log(line);
    std.out.flush();
}

Of course it assumes that input from client will be line oriented, which is a safe assumption imho

@coderofsalvation
Copy link
Contributor Author

thanks..that looks much better.
I've updated the pullrequest @asergeyev can you merge?

Copy link
Collaborator

@asergeyev asergeyev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks

@asergeyev asergeyev merged commit c91a1dd into joewalnes:master Apr 12, 2021
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.

3 participants