starmessage / libSoftMeter

Application analytics (software usage analytics) for Windows, MacOS and IOS software
https://www.starmessagesoftware.com/softmeter
Other
50 stars 23 forks source link

From a Delphi application, Greek text does not pass OK to Google Analytics #7

Closed starmessage closed 5 years ago

starmessage commented 5 years ago

When using SoftMeter to get application analytics for software compiled with Delphi, the Greek texts in the sendPageview(), sendEvent(), sendScreenview() does not appear correctly in the Google Analytics reporting.

starmessage commented 5 years ago

From the C++ console demo, Greek texts pass ok to Google Analytics. So, the problem must be related to the Delphi code, probably to the DLL linking and the PAnsiChar type that is used as a type for the string parameters in the demo Delphi program.

starmessage commented 5 years ago

First, make sure your source files are in UTF-8 encoding. Right-click on your source code in the Delphi IDE, and select File Format. Then choose UTF-8.

In Delphi XE5, go to project options, code page and enter 65001.

This fixes the problem and Greek text passes Ok to Google Analytics. image

starmessage commented 5 years ago

Delphi 7 is not unicode and the above solution cannot be applied. In Delphi 7, you can simple pass your text via the function "Utf8Encode" which is an "out-of-the-box" function in the Delphi RTL.

For example a call to sendPageView would be:
sendPageview(PAnsiChar(UTF8Encode('a page path')), PAnsiChar(UTF8Encode('a page title')) );