Giter Club home page Giter Club logo

Comments (7)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
What version did you use (or SVN revision)?

Original comment by [email protected] on 2 May 2011 at 2:11

from protobuf-java-format.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.