Comments (7)
What version did you use (or SVN revision)?
Original comment by [email protected]
on 2 May 2011 at 2:11
from protobuf-java-format.
The version used is 1.1.1
This is the email I got from the person using it:
------------------
Hi Alex,
I used your code to convert my inputStream to a String before calling
JsonFormat.merge, but I still have the same problem with the object after
returning. I verified that the string argument has the Chinese characters that
were in the input stream.
I stepped through some of the JsonFormat code and processes the token in
consumeByteString:
/**
* If the next token is a string, consume it and return its (unescaped) value. Otherwise,
* throw a {@link ParseException}.
*/
public String consumeString() throws ParseException {
return consumeByteString().toStringUtf8();
}
/**
* If the next token is a string, consume it, unescape it as a
* {@link com.google.protobuf.ByteString}, and return it. Otherwise, throw a
* {@link ParseException}.
*/
public ByteString consumeByteString() throws ParseException {
char quote = currentToken.length() > 0 ? currentToken.charAt(0) : '\0';
if ((quote != '\"') && (quote != '\'')) {
throw parseException("Expected string.");
}
if ((currentToken.length() < 2)
|| (currentToken.charAt(currentToken.length() - 1) != quote)) {
throw parseException("String missing ending quote.");
}
try {
String escaped = currentToken.substring(1, currentToken.length() - 1);
ByteString result = unescapeBytes(escaped);
The function unescapeBytes treats it as a byte string, so the characters get
lost because they aren’t contained in single bytes. Do you know why it
should be treating the token as a byte-string? I think this is the essence of
the problem.
Original comment by [email protected]
on 3 May 2011 at 4:37
from protobuf-java-format.
This was fixed by patch for issue 11. The method "unescapeBytes" is no longer
used for parsing strings.
Either use trunk or wait for the next release to get the fix.
Original comment by [email protected]
on 3 May 2011 at 12:39
- Changed state: Duplicate
from protobuf-java-format.
Philippe / Alex, please add unit test to verify this issue on trunk.
I'm re-opening this issue till verification.
Original comment by eliran.bivas
on 3 May 2011 at 12:49
- Changed state: Accepted
from protobuf-java-format.
Alex can confirm, but he added a unit test in r61. I'll let Alex close the
issue when he confirms this.
Original comment by [email protected]
on 3 May 2011 at 12:54
from protobuf-java-format.
Code reviewed, Alex - Close if you think this issue is fixed.
Original comment by eliran.bivas
on 3 May 2011 at 1:23
from protobuf-java-format.
Looks like the latest trunk has fixed the issue. Unit test is in place to
verify that future changes won't break it.
Original comment by [email protected]
on 4 May 2011 at 4:18
- Changed state: Fixed
from protobuf-java-format.
Related Issues (20)
- SmileFormat print is closing the outputstream HOT 2
- Target Java 1.5 instead of 1.6
- Common Interface for all formats HOT 5
- Code review request HOT 1
- Tokenizer bug in XmlFormat.merge HOT 1
- Escaped slash is not correctly handled HOT 3
- It just can not work for my test
- Fail for partial build
- Option to omit top-level element wrapping
- JsonFormat.merge does not parse doubles correctly for undefined field HOT 1
- invalid escapes \a and \v in output of byte array HOT 4
- Serializing a builder that has a default value, but doesn't override it, creates json without that value. HOT 1
- com.googlecode.protobuf.format.JsonFormat#escapeBytes handles '\a' incorrectly. '\a' is ivalid value for json. HOT 2
- Feature Request: Some level of Avro Support
- Unknown fields violate JSON syntax HOT 1
- (valid) empty object throws a ParseException HOT 2
- JSON parser does not accept camel-case fieldnames.
- Error while parsing Json string when a non-primitive field is null
- question about UTF8
- JSON formatting breaks when a proto Message contains UnknownFields
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protobuf-java-format.