Skip to content

Conversation

faceair
Copy link

@faceair faceair commented Jul 8, 2018

Thanks taowen, I create a new binary as string codec for my product, like this.
I want add this patch to ignore the escaped double quote when ReadStringAsSlice, if not it's hard to read "i say:\"hi\"".

@codecov
Copy link

codecov bot commented Jul 8, 2018

Codecov Report

Merging #290 into master will decrease coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #290 +/- ## ========================================== - Coverage 81.78% 81.72% -0.07%  ========================================== Files 41 41 Lines 4980 4980 ========================================== - Hits 4073 4070 -3  - Misses 793 796 +3  Partials 114 114
Impacted Files Coverage Δ
iter_str.go 90.9% <100%> (ø) ⬆️
reflect_struct_decoder.go 47.49% <0%> (-0.42%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab8a2e0...2745c1e. Read the comment docs.

@faceair faceair changed the title ignore escaped char when ReadStringAsSlice ignore escaped double quote when ReadStringAsSlice Jul 8, 2018
@taowen
Copy link
Contributor

taowen commented Jul 9, 2018

we can not change the behavior of ReadStringAsSlice as it is already being used by other users. ReadStringAsSlice does not handle any escape by design. Use ReadString instead.

@taowen taowen closed this Jul 9, 2018
@faceair
Copy link
Author

faceair commented Jul 9, 2018

Thanks, ReadString is worked. But I am a bit worried about the overhead of bytes to string conversion, it's unnecessary. Maybe I need the anothor ReadStringAsSlice function with handle escape.

@taowen
Copy link
Contributor

taowen commented Jul 9, 2018

the point of ReadStringAsSlice is reference the memory directly. If there is escape, the underlying memory will be different from the output. So make a copy like ReadString is the only strategy working.

@faceair
Copy link
Author

faceair commented Jul 9, 2018

I understand, thank you. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants