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

Message.toObject decode bytes to UTF8 String #1095

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yagop
Copy link

@yagop yagop commented Jul 25, 2018

Using option { bytes: 'utf8' } in Message.toObject will decode bytes to String (Buffer.toString()). Previos options are preserved.

@dcodeIO
Copy link
Member

dcodeIO commented Jul 25, 2018

Note that Buffer is not available in the browser. Any reason for not using the string type?

@yagop
Copy link
Author

yagop commented Jul 25, 2018

Sorry, it turns out what I need is to decode to latin1. Would be good to have multiple supported Buffer encodings.

Didn't realize about Buffer is not available in the browser :(

@dcodeIO
Copy link
Member

dcodeIO commented Jul 26, 2018

My feeling on this one is that one should use another library for custom encodings that are not part of protobuf itself.

@yagop
Copy link
Author

yagop commented Jul 26, 2018

I was trying to overwrite .toObject like on #879 but I think its not possible, it is?

@Gcaufy
Copy link

Gcaufy commented Feb 8, 2021

I agree to add an { bytes: 'utf8' } option.

Because in C++, they like to use bytes as string. bytes can be used as utf-8 string directly.

@Gcaufy
Copy link

Gcaufy commented Feb 8, 2021

in case someone else still need this:

https://github.com/Gcaufy/protobufjs.shim

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.

None yet

3 participants