68kMLA Classic Interface

This is a version of the 68kMLA forums for viewing on your favorite old mac. Visitors on modern platforms may prefer the main site.

Click here to select a new forum.
OS9 Programming & UTF-8
Posted by: paws on 2023-04-03 14:30:48
I'm writing my first MacOS application, a to do list, using C++ and the MacZoop framework (2.5.1, pre-Carbon) which reads and writes simple plain text files. My first language uses a few non-ASCII characters, so I'd like to keep the on-disk format as UTF-8 so I can share the files with more recent computers. I'm just drawing text with QuickDraw and I think the best bet is to transparently convert to MacOS Roman on saving and loading - I don't expect support for all of Unicode, I just want support for "basic European" at this point.

Technically I think I could hack some very simple byte replacements, but maybe there is a something like iconv already available on MacOS 9? I know the terms "MLTE" and "ATSUI" but I can't tell if they're actually available in a pre-Carbon environment, nor if they will do what I want. I'm happy to include a 3rd party library in my project if it's not too big.
Posted by: mathieutozer on 2024-03-05 22:43:43
Did you ever make any progress here? I'm investigating something similar. I'd be happy just to escape " and ' for a start!
Posted by: paws on 2024-03-06 11:09:18
I never got around to implementing this feature, but I did find some conversion functions in Apple's headers. I was scared off by the long prototypes though, and I think they were part of ATSUI which AFAICT is OS 8.5+ only, so it wasn't perfect for my usecase (aiming for 7.5.5 compatibility).
Posted by: cy384 on 2024-03-06 13:01:40
there's an extension called "Text Encoding Converter", if you can find developer documentation somewhere it might have what you need, but likely it's utf16.
Posted by: mathieutozer on 2024-03-07 03:00:12
I’ve had some success just replacing some scalars with ascii equivalents in Swift on my proxy server, so will probably go that route since I don’t need full Unicode. I’m aiming for system 7 support too.
Will try to track down the Text Encoding Converter too and report anything I find here!
Posted by: uyjulian on 2024-03-07 07:55:31
It shouldn't be too hard to port iconv.
Posted by: mathieutozer on 2024-03-07 08:00:30
It shouldn't be too hard to port iconv.
Yeah that was my original thought too. I took a look at the source but didn’t try to compile - if I get past the prototype stage with my app I’ll look into posting, would anyone be interested in working on it with me?
Posted by: treellama on 2024-03-07 08:13:36
There is a very basic MacRoman <-> UTF-8 converter in one of my Marathon tools: https://github.com/treellama/atque/blob/master/ferro/macroman.cpp

If your project is GPL you can use that directly. Depends on how much modern C++ support you have too, I suppose.

If one or the other of those is not true, it should be easy to get the idea from the code.
1