Skip to content

Differences between writeStringToMemory and stringToUTF8 #23009

Answered by sbc100
kalwalt asked this question in Q&A
Discussion options

You must be logged in to vote

It looks like writeStringToMemory is almost the same as stringToUTF8 except for two things:

  1. writeStringToMemory as a third argument called dontAddNull which means that string won't be null terminated.
  2. stringToUTF8 has a third argument maxBytesToWrite which allows you the limit the number of bytes written to memory.

Otherwise they looks the same and writeStringToMemory is implemented in terms of stringToUTF8:

$writeStringToMemory: (string, buffer, dontAddNull) => {
warnOnce('writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!');
var /** @type {number} */ lastChar, /**…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@kalwalt
Comment options

Answer selected by kalwalt
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants