text encoding

anthony 21 Reputation points
2020-11-16T14:56:05.18+00:00

Could some help decoding text with accent:

let 
   A=Json.FromValue({"listée"}), 
   B=Text.FromBinary(C) // ["list\u00e9e"] instead of ["listée"] 
in B 
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,784 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ehren (MSFT) 1,781 Reputation points Microsoft Employee
    2020-11-20T00:58:04.75+00:00

    Hi Anthony. Json.FromValue is simply encoding the accent character using a Unicode escape sequence. (This is allowed per the JSON spec.) As Lz pointed out, Json.Document reverses this process.

    I poked around a bit, but I'm not aware of an existing function in M that would decode such escape sequences in a raw text value.

    Ehren

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Lz._ 9,006 Reputation points
    2020-11-16T15:52:57.747+00:00

    @anthony

    let   
        A=Json.FromValue({"listée","àéèçï"}),  
        B=Json.Document(A)  
    in  
        B  
    

    It's only after reading Json.FromValue's bullet points that I +/- figured out that "Produces a JSON representation" could mean "Produces a JSON document". So I tried the above...

    0 comments No comments

  2. anthony 21 Reputation points
    2020-11-16T16:13:41.667+00:00

    not what I am looking for.

    This page json.fromvalue shows an example that I would like to use with accent:

        Text.FromBinary(Json.FromValue([A={1, true, "listée"}, B=#date(2012, 3, 25)]))
    
     //  {"A":[1,true,"list\u00e9e"],"B":"2012-03-25"}    instead of     {"A":[1,true,"listée"],"B":"2012-03-25"}
    

    Any idea ?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.