I have pasted this text from Word Document to a NAV Blob Field: ~!
@#$%^&*() ‘something’ “something more” end
And printed this blob fields through a NAV report as pdf, it looks like this:
It could not decode the Left Single Quotation, Right Single Quotation, Left Double Quotation, Right Double Quotation when printing.
This is my code.
CALCFIELDS("Additional Comments");
"Additional Comments".CREATEINSTREAM(iStream,TEXTENCODING::UTF8);
Encoding:=Encoding.UTF8;
StreamReader := StreamReader.StreamReader(iStream,Encoding,TRUE);
Here,
StreamReader is a DotNet variable of subtype System.IO.StreamReader.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
and
Encoding is a DotNet variable of subtype System.Text.Encoding.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Your suggestion will be very much appreciated to resolve the issue.
Answers
Not sure why you are using dotnets to read from a blob, NAV can handle this.
Can you try something like:
Also, I recall if you are about to read BLOBs from SQL query etc, you need to set BLOB properties compressed=false. Even if you do that, some characters are not well recognised etc.
https://andreilungu.com/read-write-text-from-to-blob-field-nav/
Then yes, you can do something like this, I used for reading an image
Thanks txeriff and PurpleHaze for your help. You are awesome.
"Additional Comments".CREATEINSTREAM(iStream1);
binRdr:=binRdr.BinaryReader(iStream1,Encoding.UTF8);
IF NOT ISNULL(binRdr) THEN BEGIN //read value from BLOB field
length:=binRdr.BaseStream.Length;
IF length > 0 THEN BEGIN
WHILE i<length DO BEGIN
var_char:=binRdr.ReadByte();
TokenText+=FORMAT(var_char);
i+=1;
END;
END;
MESSAGE('text %1',TokenText);
binRdr.Close;
END;