Rhombic question marks instead of text on generated labels

Hello everyone. After assigning generated labels to my OgrLayer shapes I experience strange problem with text encoding. Instead of the desired text I see rhombed question marks.

The problem is illustrated on the picture below:

My connection string:
public string con = @"MSSQL:server=.\sqlexpress;database=gsdb;trusted_connection=yes";
OgrDataSource initialization:
public OgrDatasource ds = new OgrDatasource();

I use this query to gather stuff:
query_azs_poly = "SELECT punkti_azs.id_azs, punkti_azs.naimenovanie, geom FROM ((azs_poly INNER JOIN punkti_azs ON azs_poly.id_azs=punkti_azs.id_azs) INNER JOIN neftekompanii ON punkti_azs.id_kompania=neftekompanii.id_kompania) INNER JOIN directori_neftekom ON neftekompanii.id_director=directori_neftekom.id_director WHERE azs_poly.id_azs IS NOT NULL AND directori_neftekom.id_director=" + mainForm.id;
For labels I use ‘punkti_azs.naimenovanie’ field.

Adding layer and labels this way:
var lr_azs_poly = ds.RunQuery(query_azs_poly); hndl_azs_poly = axMap.AddLayer(lr_azs_poly, true); Shapefile sf_azs_poly = axMap.get_Shapefile(hndl_azs_poly); sf_azs_poly.Labels.Generate("[naimenovanie]", tkLabelPositioning.lpCenter, false); sf_azs_poly.Labels.FrameVisible = true; sf_azs_poly.Labels.FrameType = tkLabelFrameType.lfRectangle;

My database is using this collation:

What can I do? Is there anything I need to do with my database collation? I have tried using GlobalSettings’ OgrStringEncoding = tkOgrEncoding.oseUtf8; but it doesnt work and produce same question marks.

Thanks in advance.

Hello @Windground

As a test, since it will pass through slightly different internal code, instead of:

sf_azs_poly.Labels.Generate("[naimenovanie]", tkLabelPositioning.lpCenter, false);

try this:

sf_azs_poly.GenerateLabels(sf_azs_poly.get_FieldIndexByName("naimenovanie"), tkLabelPositioning.lpCenter);

Thank you,

Greetings. Thank you for the answer. I tried to use this command, but unfortunately the result is the same. Is it possible in this case to specify only part of the field text to be displayed for labels? For example, instead of “������ 12345” only “12345”.

Perhaps. Not sure of the syntax, but may be able to use the SQLServer SUBSTRING capability as part of your query to just extract the numeric portion.

You may be able to do it through MapWinGIS, but the process would be different since you couldn’t use the built-in Label generation, but instead build the labels individually so that you could do a substring function. I’d have to think about the syntax for that.

@jerryfaust, I slightly modified my SQL-query and in this case only left numeric characters since the scrambled part is equal in every label.

So now the labels look like this:

I think it will be okay for the first time. Thank you for your time and patience. :slightly_smiling_face:

Ok, but I would like to resolve this if possible. We’ve done work on the labeling in an effort to support Unicode characters coming out of an OGR layer, but in your case, something is still falling through the cracks.

I’m not sure how to approach this; some options, if you are willing:

  1. If you could save your Shapefile (sf_azs_poly) to disk and upload those files to this site? It may be that the Shapefile has already lost the string detail, but I could start with that and try debugging.
  2. Another option would be to do a backup of that layer (or a subset of that layer) from SQL Server, that I could import into SQL Server on my end in order to debug?

If it’s proprietary data or you are unable to do either of these right now, that’s fine. It’s just a suggestion.