-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Conversation
bool is_extern_ascii = is_extern && str->IsExternalAscii(); | ||
if (is_extern) { | ||
if (is_extern_ascii) { | ||
str = String::NewFromOneByte(isolate, reinterpret_cast<const uint8_t*>(data), String::NewStringType::kNormalString, len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this pass make cpplint
?
Looks really good! Could you please fix some minor style issues? |
@indutny Fixed according to your suggestion. And also fixed building and test case issue on OSX. Please check this commit. |
@@ -119,12 +119,30 @@ size_t Length(Handle<Object> obj) { | |||
|
|||
Local<Object> New(Isolate* isolate, Handle<String> string, enum encoding enc) { | |||
EscapableHandleScope scope(isolate); | |||
|
|||
size_t length = StringBytes::Size(isolate, string, enc); | |||
Local<String> tmp_string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading #8683 correctly the issue is that the length computation is incorrect. Creating a temporary string doesn't seem necessary at all. Why not just the length computation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to compute the length correctly for each encoding. But creating a temporary string is the simplest way to fix this issue.
@trevnorris ... did you ever have a chance to look at this? |
@jasnell this has been fixed in nodejs/node@1640dedb3. I'd just pick that. |
This PR fixed the encoding issue of converting external string into Buffer (#8683).