With the following code in a new app window.opening event I output the current time to a TextArea using the new and old DateTime objects to test:
Var d1 As DateTime = DateTime.Now
Var DateStrNew As String = d1.ToString(Locale.Current, DateTime.FormatStyles.None, DateTime.FormatStyles.Short)
Var d2 as New Date
Var DateStrOld As String = d2.ShortTime
TextArea1.Text = DateStrNew + EndOfLine + DateStrOld
I build this app as a Universal (Intel/Arm) app.
When I run this app on Intel MBP macOS 10.15.7 I get the following output for both date objects: 1:37 pm
Loading this text into an app to show the bytes I see: 31 3A 33 37 20 70 6D
When I run this app on a M1 MacMini with macOS Sonoma (natively and via Rosetta) I get the following output for both date objects: 1:37 pm
Loading this text into an app to show the bytes I see: 31 3A 33 37 E280AF 70 6D
The space character is represented by E280AF. I’m no expert on character codes but this is breaking my app that exports the data and time in the footer of my PDF using DynaPDF as DynaPDF doesn’t understand what this is.
Can anyone reproduce this? Is this intentional or shall I log this as a Xojo bug?
The space between the time and “pm” is a Unicode Non-Breaking Space. This is a feature of typesetting that tells the rendering system “don’t break up these two pieces of text even though they have a space in between them”. So you’ll always see:
1:09 pm
and never
1:09
pm
You can safely replace it with a single space for use in your PDF:
As an aside to the Xojo engineers working on PDF support: non-breaking spaces and non-breaking hyphens are very useful in typesetting and should be a part of the PDF functionality.
No. I tried Encodings.UTF8 first as well but that doesn’t work. I spent a good hour trying to get it to work, then by mistake tried Encodings.ASCII and that works.
Yes, that’s a Unicode character in UTF-8 encoding. I would have expected that any app producing a PDF would understand about UTF-8. Otherwise how is it going to handle the many symbols not in ASCII? ?
But then when it comes for the rendering of the character, it looks into the current font to look how to draw it. and yes, some font could define to draw a symbol there!
If the font doesn’t have the character, it reports an error. And that part is something Jens may change.