Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Fix joyent/node#8683 #8744

Closed
wants to merge 3 commits into from
Closed

Fix joyent/node#8683 #8744

wants to merge 3 commits into from

Conversation

ghostoy
Copy link

@ghostoy ghostoy commented Nov 18, 2014

This PR fixed the encoding issue of converting external string into Buffer (#8683).

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);
Copy link
Member

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?

@indutny
Copy link
Member

indutny commented Nov 18, 2014

Looks really good! Could you please fix some minor style issues?

@ghostoy
Copy link
Author

ghostoy commented Nov 19, 2014

@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;

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?

Copy link
Author

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 trevnorris self-assigned this Feb 11, 2015
@jasnell
Copy link
Member

jasnell commented Aug 13, 2015

@trevnorris ... did you ever have a chance to look at this?

@trevnorris
Copy link

@jasnell this has been fixed in nodejs/node@1640dedb3. I'd just pick that.

@Trott Trott closed this Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants