Menu

#76 Encode Text Error for special language chars

0.1.2.1
closed-out-of-date
encoding (1)
5
2015-06-04
2015-06-03
Andrea M.F.
No

When I add text through the ShowText() method, Unicode characters like Polish ones cause an exception.

Example:
This Polish text = " INTERPRETACJA DOKONANA BEZ ZNANEJ PŁCI/WIEKU PACJENTA "
causes codes.GetKey(..) in Encode(string Text) to fail on 'Ł'.

  /**
      <summary>Gets the internal representation of the given text.</summary>
      <param name="text">Text to encode.</param>
    */
    public byte[] Encode(
      string text
      )
    {
      io::MemoryStream encodedStream = new io::MemoryStream();
      for(int index = 0, length = text.Length; index < length; index++)
      {
        int textCode = text[index];
        byte[] charCode = codes.GetKey(textCode).Data;
        encodedStream.Write(charCode, 0, charCode.Length);
        usedCodes.Add(textCode);
      }
      encodedStream.Close();
      return encodedStream.ToArray();
    }

Discussion

  • Stefano Chizzolini

    • labels: Dictionary Language --> encoding
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,11 +1,10 @@
    -When pass to composer trought the function ShowText() some text wich contains some language special char (like polish) it produce an error.
    +When I add text through the ShowText() method, Unicode characters like Polish ones cause an exception.
    
     Example:
    -This polish text = "** INTERPRETACJA DOKONANA BEZ ZNANEJ PŁCI/WIEKU PACJENTA **"
    -cointains the char 'Ł' when 
    -call the Encode(string Text) it produce an error into the codes.GetKey...
    +This Polish text = "** INTERPRETACJA DOKONANA BEZ ZNANEJ PŁCI/WIEKU PACJENTA **"
    +causes codes.GetKey(..) in Encode(string Text) to fail on 'Ł'.
    
    -
    +~~~~
       /**
           <summary>Gets the internal representation of the given text.</summary>
           <param name="text">Text to encode.</param>
    @@ -25,4 +24,4 @@
           encodedStream.Close();
           return encodedStream.ToArray();
         }
    -
    +~~~~
    
     
  • Stefano Chizzolini

    Please try the latest update:
    http://sourceforge.net/p/clown/code/HEAD/tarball?path=/branches/0.1.2-Fix

    If the problem persists, please verify whether the font you are using supports Polish characters: in such a case, please send me your font file so I'm able to examine the issue.
    thank you

     
    • Andrea M.F.

      Andrea M.F. - 2015-06-04

      Yes,
      now it works perfectly.

      Many thanks for your fast reply.

      Andrea Falappi

       

      Last edit: Stefano Chizzolini 2015-06-04
  • Stefano Chizzolini

    • status: open --> closed-out-of-date
     

Log in to post a comment.

MongoDB Logo MongoDB