The ansi2ascii tool, license problem

galmokgalmok Member Posts: 44
As I don't have a developer license, I think I have put myself in a bad position. I downloaded the Ansi <-> Ascii converter tool (http://www.mibuso.com/dlinfo.asp?FileID=287) as I am importing data into Navision. I need to convert the data as foreign characters look weird in Navision.

I imported the fob file before I noticed that I wasn't allowed to run it (can't run codeunits with the number 99999). Ok, I'll just remove it again I thought, but no, Navision doesn't let me remove it. Bummer. What is my option now? Should I just let it be seeing as it doesn't harm anything directly or pay to have it removed?

Also, seeing as I couldn't run this code unit, I figured I had to recreate the functions in my dataport. I did that by copy-pasting the code, but the converted strings are not working. Probably due to the codeunit being written in a codepage and the copy-paste working in another. So, how do I copy-paste the code so that it works? :-)

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Maybe you can try the approach as described in Delete object in Import Worksheet?
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • galmokgalmok Member Posts: 44
    Thank you for the suggestion, but the mentioned method requires a Codeunit number 99999 to be created to be able to use this trick. I, however, don't have the license to be able to create a codeunit. I guess I'll just let it be.

    I still have my conversion problem which I am trying to debug..
  • galmokgalmok Member Posts: 44
    Is there an error in the mapping in the ansi <-> ascii converter tool?

    When calling Ansi2Ascii on a string, all spaces are converted to "ÿ". This is clearly wrong.

    Looking at the code I see that the last character in AnsiStr is a space and the last character in AsciiStr is ÿ. CONVERTSTR does what it should and converts space to ÿ, but space should be converted to space...

    Also, "Å" is converted to a square (unprintable). Other characters are also causing problems.

    I may use it wrongly or my initial copy-paste ruined the characters, but looking in the fob file for my dataport, it looks correct (matches the ansi<->ascii fob file.

    Anyway, I am now building my own translation according to the image found on this page:

    http://www.torsten-horn.de/techdocs/ascii.htm

    This seems to be working well.
  • PoltergeistPoltergeist Member Posts: 200
    The fob is correct, except for one thing: it was made in 1998, before the Euro. The first character in the ansistring should be different (character code 199, I believe)
  • jversusjjversusj Member Posts: 489
    galmok wrote:
    Is there an error in the mapping in the ansi <-> ascii converter tool?

    When calling Ansi2Ascii on a string, all spaces are converted to "ÿ". This is clearly wrong.

    Looking at the code I see that the last character in AnsiStr is a space and the last character in AsciiStr is ÿ. CONVERTSTR does what it should and converts space to ÿ, but space should be converted to space...

    Also, "Å" is converted to a square (unprintable). Other characters are also causing problems.

    I may use it wrongly or my initial copy-paste ruined the characters, but looking in the fob file for my dataport, it looks correct (matches the ansi<->ascii fob file.

    Anyway, I am now building my own translation according to the image found on this page:

    http://www.torsten-horn.de/techdocs/ascii.htm

    This seems to be working well.
    We used the ansi-ascii tool and found quite a few characters that had to be remapped by our NSC. We also had a problem with spaces - but ours was a natural space vs a long space. We loaded everything as long spaces in error and had to remap the converter and start over. Otherwise, you couldn't search customers by name if they had more than one word in their name. good luck!
    kind of fell into this...
  • galmokgalmok Member Posts: 44
    I have recreated the full mapping by using the ALT-0128 and ALT-128 keyboard input method, using the CharVar when the produced character was wrong. Everything seems ok now.

    This is the mapping I ended up with (is probably not copy-paste proof):
    CharVar[1] := 196;
    CharVar[2] := 197;     // 143
    CharVar[3] := 201;
    CharVar[4] := 242;
    CharVar[5] := 220;
    CharVar[6] := 186;
    CharVar[7] := 191;
    CharVar[8] := 188;
    CharVar[9] := 187;
    CharVar[10] := 193;
    CharVar[11] := 194;
    CharVar[12] := 192;
    CharVar[13] := 195;
    CharVar[14] := 202;
    CharVar[15] := 203;
    CharVar[16] := 200;
    CharVar[17] := 205;
    CharVar[18] := 206;
    CharVar[19] := 204;
    CharVar[20] := 175;
    CharVar[21] := 223;
    CharVar[22] := 213;
    CharVar[23] := 254;
    CharVar[24] := 218;
    CharVar[25] := 219;
    CharVar[26] := 217;
    CharVar[27] := 180;
    CharVar[28] := 177;
    CharVar[29] := 176;
    CharVar[30] := 185;
    CharVar[31] := 179;
    CharVar[32] := 178;
    CharVar[33] := 160;
    CharVar[34] := 221;
    CharVar[35] := 255;
    AsciiStr := '€‚ƒ„…†‡ˆ‰Š‹ŒŽ';  // 128 - 143
    AnsiStr  := 'ÇüéâäàåçêëèïîìÄÅ';
    AsciiStr := AsciiStr + '‘’“”•–—˜™š›œžŸ';  // 144 - 159
    AnsiStr  := AnsiStr  + 'ÉæÆôöòûùÿÖÜø£Ø׃';
    AsciiStr := AsciiStr + FORMAT(CharVar[33])+'¡¢£¤¥¦§¨©ª«¬­®¯'; // 160 - 175
    AnsiStr  := AnsiStr  + 'á'                +'íóúñѪº¿®¬½¼¡«»';
    AsciiStr := AsciiStr + '°'                +'±'                +'²'; // 176 - 178
    AnsiStr  := AnsiStr  + FORMAT(CharVar[29])+FORMAT(CharVar[28])+FORMAT(CharVar[32]);
    AsciiStr := AsciiStr + '³'                +'´'                +'µ¶·¸'; // 179 - 184
    AnsiStr  := AnsiStr  + FORMAT(CharVar[31])+FORMAT(CharVar[27])+'ÁÀ©';
    AsciiStr := AsciiStr + '¹'                +'º'               +'»';  // 185 - 187
    AnsiStr  := AnsiStr  + FORMAT(CharVar[30])+FORMAT(CharVar[6])+FORMAT(CharVar[9]);
    AsciiStr := AsciiStr + '¼'               +'½¾¿';  // 188 - 191
    AnsiStr  := AnsiStr  + FORMAT(CharVar[8])+'¢¥'+FORMAT(CharVar[7]);
    AsciiStr := AsciiStr + 'À'                +'Á'                +''; // 192 - 194
    AnsiStr  := AnsiStr  + FORMAT(CharVar[12])+FORMAT(CharVar[10])+FORMAT(CharVar[11]);
    AsciiStr := AsciiStr + 'Ã'                +'Ä'               +'Å'; // 195 - 197
    AnsiStr  := AnsiStr  + FORMAT(CharVar[13])+FORMAT(CharVar[1])+FORMAT(CharVar[2]);
    AsciiStr := AsciiStr + 'ÆÇÈ'                   +'É'               +'Ê'; // 198 - 202
    AnsiStr  := AnsiStr  + 'ãÃ'+FORMAT(CharVar[16])+FORMAT(CharVar[3])+FORMAT(CharVar[14]);
    AsciiStr := AsciiStr + 'Ë'                +'Ì'                +'Í'; // 203 - 205
    AnsiStr  := AnsiStr  + FORMAT(CharVar[15])+FORMAT(CharVar[19])+FORMAT(CharVar[17]);
    AsciiStr := AsciiStr + 'Î'                +'Ï'; // 206 - 207
    AnsiStr  := AnsiStr  + FORMAT(CharVar[18])+'¤';
    AsciiStr := AsciiStr + 'ÐÑÒÓÔÕÖ×ØÙ'                   +'Ú'; // 208 - 218
    AnsiStr  := AnsiStr  + 'ðÐÊËÈ'+FORMAT(CharVar[22])+'ÍÎÏ'+FORMAT(CharVar[16])+FORMAT(CharVar[24]);
    AsciiStr := AsciiStr + 'Û'                +'Ü'               +'Ý'; // 219 - 221
    AnsiStr  := AnsiStr  + FORMAT(CharVar[25])+FORMAT(CharVar[5])+FORMAT(CharVar[34]);
    AsciiStr := AsciiStr + 'Þß'; // 222 - 223
    AnsiStr  := AnsiStr  + 'Ì'+FORMAT(CharVar[21]);
    AsciiStr := AsciiStr + 'àáâãäåæçèéêëìíîï'; // 224 - 239
    AnsiStr  := AnsiStr  + 'ÓßÔÒõÕµþÞÚÛÙýݯ´';
    AsciiStr := AsciiStr + 'ðñò'                  +'óôõö÷øùúûüýþ'; // 240 - 254
    AnsiStr  := AnsiStr  + '­±'+FORMAT(CharVar[4])+'¾¶§÷¸°¨·¹³²'+FORMAT(CharVar[23]);
    AsciiStr := AsciiStr + 'ÿ';
    AnsiStr  := AnsiStr  + FORMAT(CharVar[35]);
    
  • MarianoMMarianoM Member Posts: 2
    jversusj wrote:
    We used the ansi-ascii tool and found quite a few characters that had to be remapped by our NSC. We also had a problem with spaces - but ours was a natural space vs a long space. We loaded everything as long spaces in error and had to remap the converter and start over. Otherwise, you couldn't search customers by name if they had more than one word in their name. good luck!

    First of all, I'm new here, so greetings to everyone :D

    I know this post is a bit old, but I'm having the same problem with space characters and I haven't found a solution yet.
    Could you tell me what you did to solve this?

    Thanks in advance.
  • jversusjjversusj Member Posts: 489
    MarianoM wrote:
    jversusj wrote:
    We used the ansi-ascii tool and found quite a few characters that had to be remapped by our NSC. We also had a problem with spaces - but ours was a natural space vs a long space. We loaded everything as long spaces in error and had to remap the converter and start over. Otherwise, you couldn't search customers by name if they had more than one word in their name. good luck!

    First of all, I'm new here, so greetings to everyone :D

    I know this post is a bit old, but I'm having the same problem with space characters and I haven't found a solution yet.
    Could you tell me what you did to solve this?

    Thanks in advance.
    hello.

    we had help - some remapping.

    here is the C/AL we used in that CU (hopefully not goofed up by copy-paste).
    OBJECT Codeunit 50109 ANSI <-> ASCII converter
    {
      OBJECT-PROPERTIES
      {
        Date=10/19/06;
        Time=10:00:25 AM;
        Modified=Yes;
        Version List=NSDK;
      }
      PROPERTIES
      {
        OnRun=VAR
                Slimslam@1000000000 : Text[30];
                Slimslam2@1000000001 : Text[54];
              BEGIN
              END;
    
      }
      CODE
      {
        VAR
          AsciiStr@1000000000 : Text[250];
          AnsiStr@1000000001 : Text[250];
          CharVar@1000000002 : ARRAY [33] OF Char;
          x@1000000003 : Integer;
          outtext@1000000005 : Text[250];
          pos@1000000004 : Integer;
          textstr@1000000006 : Text[1];
          textstr2@1000000007 : Text[1];
    
        PROCEDURE Ansi2Ascii@9(_Text@1000000000 : Text[250]) : Text[250];
        BEGIN
          MakeVars;
    
          {
          FOR x:=1 TO STRLEN(_Text) DO BEGIN
          textstr[1] := _Text[x];
          pos := STRPOS(AnsiStr, textstr);
          IF pos > 0 THEN BEGIN
            textstr2[1] := AsciiStr[pos];
            MESSAGE(FORMAT(pos)+' '+textstr2);
          END;
          END;
           }
    
          outtext := CONVERTSTR(_Text,AnsiStr,AsciiStr);
          EXIT(outtext);
        END;
    
        PROCEDURE Ascii2Ansi@10(_Text@1000000000 : Text[250]) : Text[250];
        BEGIN
          MakeVars;
          EXIT(CONVERTSTR(_Text,AsciiStr,AnsiStr));
        END;
    
        PROCEDURE MakeVars@1();
        BEGIN
          AsciiStr := '€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯ÝÝÝÝݵ¶·¸ÝÝ++½¾++--+-+ÆÇ++--Ý-+';
          AsciiStr := AsciiStr +'ÏÐÑÒÓÔiÖ×Ø++Ý_ÝÞîàáâãäåæçèéêëìíîïðñ=óôõö÷øùúûüýÝ ';
          CharVar[1] := 196;
          CharVar[2] := 197;
          CharVar[3] := 201;
          CharVar[4] := 242;
          CharVar[5] := 220;
          CharVar[6] := 186;
          CharVar[7] := 191;
          CharVar[8] := 188;
          CharVar[9] := 187;
          CharVar[10] := 193;
          CharVar[11] := 194;
          CharVar[12] := 192;
          CharVar[13] := 195;
          CharVar[14] := 202;
          CharVar[15] := 203;
          CharVar[16] := 200;
          CharVar[17] := 205;
          CharVar[18] := 206;
          CharVar[19] := 204;
          CharVar[20] := 175;
          CharVar[21] := 223;
          CharVar[22] := 213;
          CharVar[23] := 254;
          CharVar[24] := 218;
          CharVar[25] := 219;
          CharVar[26] := 217;
          CharVar[27] := 180;
          CharVar[28] := 177;
          CharVar[29] := 176;
          CharVar[30] := 185;
          CharVar[31] := 179;
          CharVar[32] := 178;
          CharVar[33] := 160;
    
          AsciiStr[87] := 228;
          AsciiStr[54] := 219;
          AsciiStr[72] := 222;
          AsciiStr[56] := 218;
          AsciiStr[84] := 226;
          AsciiStr[55] := 220;
          AsciiStr[85] := 223;
          AsciiStr[89] := 231;
          AsciiStr[30] := 'î';
    
          AnsiStr  := 'Çüéâäàåçêëèïîì'+FORMAT(CharVar[1])+FORMAT(CharVar[2])+FORMAT(CharVar[3])+ 'æÆôö'+FORMAT(CharVar[4]);
          AnsiStr := AnsiStr + 'ûùÿÖ'+FORMAT(CharVar[5])+'ø£Ø׃áíóúñѪ'+FORMAT(CharVar[6])+FORMAT(CharVar[7]);
          AnsiStr := AnsiStr + '®¬½'+FORMAT(CharVar[8])+'¡«'+FORMAT(CharVar[9])+'___¦¦' + FORMAT(CharVar[10])+FORMAT(CharVar[11]);
          AnsiStr := AnsiStr + FORMAT(CharVar[12]) + '©¦¦++¢¥++--+-+ã' + FORMAT(CharVar[13]) + '++--¦-+¤ðÐ';
          AnsiStr  :=  AnsiStr +FORMAT(CharVar[14])+FORMAT(CharVar[15])+FORMAT(CharVar[16])+'i'+FORMAT(CharVar[17])+FORMAT(CharVar[18]);
          AnsiStr  :=  AnsiStr + 'Ï++__¦' + FORMAT(CharVar[19])+FORMAT(CharVar[20])+'Ó'+FORMAT(CharVar[21])+'ÔÒõ';
          AnsiStr  :=  AnsiStr + FORMAT(CharVar[22]) + 'µ' + FORMAT(CharVar[23]) + 'Þ' + FORMAT(CharVar[24])+ FORMAT(CharVar[25]);
          AnsiStr  :=  AnsiStr + FORMAT(CharVar[26]) + 'ýݯ' + FORMAT(CharVar[27]) + '­' + FORMAT(CharVar[28]) +'=¾¶§÷¸'+ FORMAT(CharVar[29]
          );
          AnsiStr  :=  AnsiStr + '¨·' + FORMAT(CharVar[30]) +FORMAT(CharVar[31]) +FORMAT(CharVar[32]) +'_'+FORMAT(CharVar[33]);
        END;
    
        BEGIN
        END.
      }
    }
    
    kind of fell into this...
  • PoltergeistPoltergeist Member Posts: 200
    Please remember that various languageversions of navision use a different charactermap (I found out the hard way...) so the ansi2ascii tool should be different.
  • MarianoMMarianoM Member Posts: 2
    Thanks, I'll try it to see if this works for me.
Sign In or Register to comment.