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

Encode the command string as a Windows wide-character string (UTF-16LE) #97

Closed
wants to merge 1 commit into from

Conversation

rgl
Copy link

@rgl rgl commented Oct 25, 2019

This addresses #96

d := utf16.Encode([]rune(s))
b := make([]byte, len(d)*2)
for i, r := range d {
b[i*2] = byte(r)
Copy link
Owner

Choose a reason for hiding this comment

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

I think to be on the safe side that it would be better to use:

binary.LittleEndian.PutUint16(b[i*2:], r)

Copy link
Author

Choose a reason for hiding this comment

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

Why do you think its unsafe?

Copy link
Owner

Choose a reason for hiding this comment

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

Maybe safe wasn't the correct word. It's definitely easier to use the standard library way of doing things and possibly correct on all platforms.

@masterzen
Copy link
Owner

I'm closing this PR in favor of #111. Thanks for your help on this topic.

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.

2 participants