[CLOSED] How do I recover my original string, with accents?

  1. #1

    [CLOSED] How do I recover my original string, with accents?

    Hi

    In my gridPanel, the directEvent SelectionChange call my procedure SelectionChanged, passing to the procedure the values of selected row, as follow:

    <DirectEvents>
       <SelectionChange OnEvent="lstAgendasSalasSGE_SelectionChanged"
            Failure="Ext.MessageBox.alert('Load failed', 'Error during ajax event!');">
            <ExtraParams>                    
                <ext:Parameter Name="values" Value="Ext.encode(#{lstAgendasSalasSGE}.getRowsValues({selectedOnly:true}))" Mode="Raw" Encode="true" />
            </ExtraParams>
       </SelectionChange>
    </DirectEvents>
    the values that I get in my procedure are serialized in Json, as follow...

    ""[{\"IDAgendaSala\":3,\"Descricao\":\"Sala Igua\\u00e7u\",\"Detalhes\":\"\"}]""
    note that the value of Description modelfield are with a code instead of ç (c cedilha, character widely used in Brazil)...
    Is thus: Sala Igua\\u00e7u
    and should be as follows: Sala Iguaçu

    this happens with all my accented characters

    I try deserialize the Json string with this code

    Ext.Net.JSON.Deserialize(JsonString.Trim)
    Am I doing something wrong? I´m missing some step?

    Thanks for any help.
    Last edited by Daniil; Jan 25, 2012 at 12:18 PM. Reason: Please use [CODE] tags for any code, [CLOSED]
  2. #2
    Hi,


    Deserialization process doesn't decode unicode escape symbols


    Try to pass deserialized string through the following function
    public string DecodeUnicodeCharacters( string value ) {
            return Regex.Replace(
                value,
                @"\\u(?<Value>[a-zA-Z0-9]{4})",
                m => {
                    return ((char) int.Parse( m.Groups["Value"].Value, NumberStyles.HexNumber )).ToString();
                } );
        }
  3. #3
    Hi,

    Please remove one encoding:
    Ext.encode()
    or
    Encode="true"
    There is
    Ext.encode(Ext.encode());
    I guess it should solve the problem.
  4. #4
    Ok, Thanks...

    Removing the tag
    Encode
    , worked...

    I had created the role suggested by Vladimir, in VB ... follows, if it is useful to someone

        Public Shared Function DecodeUnicodeCharacteres(v As String) As String
            'tenho que percorrer a string, e onde encontrar \u, pegar os 4 próximos cararectres (que estão em hexadecimal) e converter o valor deles para toString
            Dim vPos As Integer
    
            vPos = InStr(1, v, "\u")
            Do While vPos <> 0
                v = v.Replace(Mid(v, vPos, 6), Chr(Integer.Parse(Mid(v, vPos + 2, 4), Globalization.NumberStyles.HexNumber)))
                vPos = InStr(1, v, "\u")
            Loop
    
            Return v
    
        End Function

Similar Threads

  1. [CLOSED] pls help how to recover svn password
    By dev in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 03, 2011, 5:06 PM
  2. Replies: 1
    Last Post: Feb 28, 2011, 8:13 AM
  3. Recover values in selected items GridPanel
    By Dominik in forum 1.x Help
    Replies: 2
    Last Post: Jun 22, 2010, 8:19 AM
  4. [CLOSED] Original values in ext:Store
    By Christof in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 17, 2010, 1:17 PM
  5. Replies: 3
    Last Post: Nov 12, 2008, 5:16 AM

Tags for this Thread

Posting Permissions