Error with some jpg files in TADVStringGrid.

We are using Delphi Seattle. I have a recent problem in the ADVStringGrid, using mini-html code.
We add an image to a cell using the following code snippet

A HREF="IMG' + sImg + '" IMG SRC="file://' + sImg + '" width="100"
Where sImg is a string var containing the path and file name.
This has worked well for years.
Within the last two weeks we have started to see an error occur with some of the .jpg files. The error states "No mapping for the Unicode Character exists in the target multi-byte code page" .
The file name characteristics are not different than any other file names that do work.
The only deviation I can see is in looking at the properties of the jpg, it show as 8 bit depth.
If I open the jpg in something like Paint, and simply resave it, it works fine. When I check on the properties of the jpg, it is now 24 bit depth.

The same error occurs with these files on a TADVGDIPPicture image import.

Any ideas would be gratefully received.

I cannot reproduce this.
Test code:

 advstringgrid1.Cells[1,1] := '<img src="file://e:\tms\temp\1619773880183.jpg">';

If a problem persists, please send a sample source project + steps with which this can be reproduced.

Thank you Bruno . All I can do is send you a copy of one of the jpgs in question. As I mentioned, most of the time it works fine, it just fails with a jpg in a specific format, with an 8 bit depth. We have used the same code as you mentioned for years with no issue. I will create a support ticket and upload the file.

Hello Bruno

Thank you for your help. I don’t think it is your component (TADVStringGrid) , but a call made to the System.SysUtils.TEncoding.GetString. The error is raised at this section of code

Len := GetCharCount(Bytes, ByteIndex, ByteCount);

if (ByteCount > 0) and (Len = 0) then

raise EEncodingError.CreateRes(@SNoMappingForUnicodeCharacter);

Unfortunately, the ADVStringGrid and other TMS components are where I have the problem.

The images are typically radiographs and so tend to be grayscale. This is why their bit depth is only 8 compared to the normal 24 (8x3) of a regular jpg. I think these might not be actual jpgs because I thought jpgs were fixed at 24 but perhaps some sort of bitmap improperly renamed. As mentioned , if I open one of these jpgs and save them in paint, it works fine.

Enclosed is one of the jpgs

This is also being done in Seattle which I understand might have had some Unicode issues. Its more than likely it works in anything higher.

Best Regards


I have retested this here with Delphi 10.2 and the same code:

procedure TForm1.Button1Click(Sender: TObject);
  advstringgrid1.Cells[1,1] := '<img src="file://e:\tms\temp\766129d144ecd69a15036db97b17bf83d6d226fd.jpeg">';

but I could not see an issue here.