[PROJ] PROJ and Unicode on Windows
Bert Huijben
bert at qqmail.nl
Thu Apr 6 08:32:40 PDT 2023
Hi Peter,
�
When I needed proj for my work on my previous day-job, I spend a bit extra time and created a complete wrapping C# library that is still used there and a few other places. The wrapping is specifically targeted towards Windows, but works there with .Net Framework and .Net core. See https://github.com/ampscm/sharpproj/ (or just use SharpProj from NuGet)
�
�
The sample code I have on that page shows +- what you try here, so you should be able to use that to try your use-cases around encoding.
�
[[
using SharpProj;
�
using var rd = CoordinateReferenceSystem.CreateFromEpsg(28992);
using var wgs84 = CoordinateReferenceSystem.CreateFromEpsg(4326);
�
var area = rd.UsageArea;
Assert.AreEqual("Netherlands - onshore, including Waddenzee, Dutch Wadden Islands and 12-mile offshore coastal zone.", area.Name);
�
using (var t = CoordinateTransform.Create(rd, wgs84))
{
var r = t.Apply(new PPoint(155000, 463000));
Assert.AreEqual(new PPoint(52.155, 5.387), r.ToXY(3)); // Round to 3 decimals for easy testing
}
]]
�
If you pick EPSG 23031, you will see that the encodings work there.
�
�
You can check all the sourcecode too, if you just want to check how to get the en-/decoding to work. (It is all Apache licensed, so feel free to copy&paste… or provide pull requests if you want something added to the library)
�
Bert
�
�
�
From: PROJ <proj-bounces at lists.osgeo.org> On Behalf Of Even Rouault
Sent: Wednesday, April 5, 2023 11:53 PM
To: Peter Townsend <peter.townsend at maplarge.com>; proj <proj at lists.osgeo.org>
Subject: Re: [PROJ] PROJ and Unicode on Windows
�
Peter,
there isn't any issue in your build. It is just that PROJ returns UTF-8 encoded strings and that the typical Windows console isn't configured to display UTF-8. Cf https://stackoverflow.com/questions/57131654/using-utf-8-encoding-chcp-65001-in-command-prompt-windows-powershell-window or similar issues
Even
Le 05/04/2023 à 23:44, Peter Townsend via PROJ a écrit �:
I've got a bit of an annoyance with my windows proj build. Hopefully it's not too hard to resolve as the world of char/wchar_t/etc. isn't something I'm terribly familiar with.
�
Take for example the area of use of EPSG:23031. On Linux it's fine, but on windows there's a unicode issue.
�
PJ* crs = proj_create(m_ctxt, "EPSG:23031");
ASSERT_NE(crs, nullptr);
ObjectKeeper keeper_crsH(crs);
double w, s, e, n;
const char* a;
proj_get_area_of_use(m_ctxt, crs, &w, &s, &e, &n, &a);
�
Contents of a:
"Europe - between 0°E and 6°E - Andorra; Denmark (North Sea); Germany offshore; Netherlands offshore; Norway including Svalbard - onshore and offshore; Spain - onshore (mainland and Balearic Islands); United Kingdom (UKCS) offshore."
�
Is there a simple thing I'm overlooking in the build process that might clear up the encoding goof? Or do I need to do some bending over backwards with character manipulation?
�
This is the command line I'm using to build this example:
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=C:\dev\vcpkg\scripts\buildsystems\vcpkg.cmake ..
cmake --build . --config Debug -j 8
�
Thanks!
--
Peter Townsend
Senior Software Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20230406/3a01e447/attachment.htm>
More information about the PROJ
mailing list