Special characters (æ ø å) in record link Notes

Hi proffs,

I need some help and I hope one of you maybe got the answer or an idea which can lead me to a solution.

I am tasked with moving text from sales line description into “Record Link” (Table: 2000000068) (field Note, BLOB)

Which under normal circumstance is easy enough but the customer is Danish and need to insert special danish characters (æ ø å).

When I use a normal Note element (NAV 2015) It works like a charm, but when I do it by code it is failing. I have trying a lot of differing methods. But UFT, text conversion, and so one. I think I have tried every I can find by google, dynamics user, mibuso.

https://postimg.org/image/gs3qwnduf/

I tried to use .NET when I could not find any other solution in C/AL, but I cannot crack the encryption, when get the data out from SQL it is a binary like “AkV9WxMISS0uUUhMUzi8TOHwDoXDSwE=”( LINQ to SQL (binary Record_Link.Note)) ,does anybody have a way to turn it into a string so I can pass it into NAV again? Or as a byte array

https://postimg.org/image/aggapaaw7/

Does any of your great minds have an idea on how to solve this one?

That’s about the only time I don’t like being Danish! Despite Navision being Danish, then NAV really don’t like our three extra letters. Especially the Ø used to cause troubles.

But I can see that you’re using BigTexts. Have you tried using a stream instead? Here you are able to specify the TEXTENCODING directly.

https://msdn.microsoft.com/en-us/library/dn271702(v=nav.80).aspx

Last time I had to get it to work directly, it also took me hours to get right… [:(]

Hi Erik,

I do agree with you so much, it has been a great pain, but with the little change you suggested:

RecLink.Note.CREATEOUTSTREAM(oStream,TEXTENCODING::Windows);

It now works like a charm, thank you so much.

For future reference if anybody is searching for the same solution, I did the following:


Text2NoteText(NoteToImport : Text[1024]) NAVNode : Text[1024]
NAVNode := UTF8Encode(NoteToImport);
NoteLength := STRLEN(NAVNode);
IF NoteLength <= 255 THEN BEGIN
  Char1 := NoteLength;
  NAVNode := FORMAT(Char1) + NAVNode;
  Char2 := 1;
END ELSE BEGIN
  Char1 := 128 + (NoteLength - 256) MOD 128;
  Char2 := 2 + (NoteLength - 256) DIV 128;
  NAVNode := FORMAT(Char1) + FORMAT(Char2) + NAVNode;
END;

UTF8Encode(String2Encode : Text[1024]) EncodedString : Text[1024]
String2Encode := TextHelper.Unicode2Ascii(String2Encode);
FOR Index := 1 TO STRLEN(String2Encode) DO BEGIN
  Char2 := String2Encode[Index];
  IF Char2 <= 127 THEN
    EncodedString := EncodedString + FORMAT(Char2)
  ELSE IF Char2 <= 192 THEN BEGIN
    Char1 := 194;
    EncodedString := EncodedString + FORMAT(Char1) + FORMAT(Char2);
  END ELSE BEGIN
    Char1 := 195;
    Char2 := Char2 - 64;
    EncodedString := EncodedString + FORMAT(Char1) + FORMAT(Char2);
  END;
END;

The TextHelper Codeunit is found on Gunnar’s blog (http://dynamics.is/)

When I create to outstream in record links I add (Like Erik suggested) TEXTENCODING::WINDOWS

RecLink.Note.CREATEOUTSTREAM(oStream,TEXTENCODING::Windows);

And that finally solved my problem

Happy it works you, and thanks for sharing the code.

No matter how many times I work with Danish characters, then it remains a mystery to me why this have to be so complex. Even with the new TEXTENCODING functions, then I always have to change my code several times, before it works again in a new context. Especially when importing/export.

Microsoft should be able to do this better!