Thank you a lot Tatu, that really explains; specially in the application that happened which deal with many time zones and locales.
On Fri, 15 Nov 2019 at 18:43, Tatu Saloranta <[email protected]> wrote: > On Thu, Nov 14, 2019 at 2:20 AM Guido Medina <[email protected]> wrote: > > > > Hi all, how can I prevent this from happening? > > > > Caused by: com.fasterxml.jackson.core.JsonGenerationException: Broken > surrogate pair: first char 0xD83C, second 0x002E; illegal combination > > at > com.fasterxml.jackson.core.JsonGenerator._reportError(JsonGenerator.java:2080) > > at = > > This means that you are trying to encode a Java String with invalid > contents: one that contains UCS-2 character that is invalid for > Unicode content. Unicode code points beyond 16-bit range are encoded > in UCS-2 (which is how Java Strings are internally represent) by 2 > `char`s, but only a subset of values are valid. > > If you are not familiar with "surrogate pairs", you can see f.ex here: > > https://stackoverflow.com/questions/5903008/what-is-a-surrogate-pair-in-java > for more explanation > > The problem for encoder, specifically, is that these `char`s are not > legal to encode separately for UTF-8. So although JDK does not prevent > their use (they are sort of bolt-on to original Java/JDK approach... > somewhere between Unicode 1 and 2 addition I think), they are not > valid for other Unicode encodings such as UTF-8. > > To add insult to injury, JSON spec actually DOES allow encoding these > using backlash escapes... but that is not available with binary > encodings (and TBH really really should not be allowed in JSON either > but here we are). > > So the fix is to figure out what exactly is producing this invalid content. > > -+ Tatu +- > > -- > You received this message because you are subscribed to the Google Groups > "jackson-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jackson-user/CAL4a10gwzTtZkE6fUNyHfsNXD1KNipkktjW5q4fgo-3WySzOig%40mail.gmail.com > . > -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/CAJsS9NM92%3DhW959ai0F1rLgvYPqf2qtAeP-EyTDa1VtfEVPgOQ%40mail.gmail.com.
