News:

Status: CAVOK

Main Menu

Unicode bug in FSX flightplans

Started by B21, January 21, 2010, 09:26:29 AM

Previous topic - Next topic

B21

Msoft switched from ascii to Unicode for the flightplan with FSX (but not the other FSX text files...) It seems like the Plan-G FSX flightplan isn't being written quite correctly as a Unicode file...

I've attached a simple Plan-G plan to show the issue - simplest test is to open it in Wordpad and you see the 'degree symbols' display incorrectly in fields such as DepartureLLA. I was able to use a text editor (the excellent freeware Crimson Editor) to load the file and then save it as Unicode, which worked fine.

FSX *will* read the Plan-G flightplan ok, so its input routine is ignoring the text between the degrees and minutes (where the degree symbol appears), so this isn't an issue for most of your users. I am reading flightplans into my FSX module sim_logger (an IGC-format secure logging utility) and hit a glitch reading Plan-G flightplans, although I was reading FSX flightplans without a problem so I took a deeper look. I've implemented a workaround in sim_logger (mentioned below) but thought you should be aware.

(In VC++) I open the flightplan file for a unicode read:
fopen_s(&f, filepath, "r, ccs=UNICODE")
then loop reading in lines with
fgetws(in_buf, MAXBUF, f)

Given an LLA string such as
<DepartureLLA>N50° 55' 32.08",W0° 28' 12.51",+000107.30</DepartureLLA>
I use sscanf with the format string including the degree symbol
"%c %d° %d' %f\", %c %d° %d' %f"
(FYI I ignore the altitude element on the end)

This works for FSX but for Plan-G it fails to parse the record due to the 'degree symbol' issue.  My workaround is to modify the sscanf format string
"%c %d %*s %d' %f\", %c %d° %d' %f"
i.e. there is  %*s (ignore multiple non-whitespace chars) where the degree symbol used to be.

My guess  is when you open the file for writing, you're not using the 'open unicode text file for writing' call in whatever language you're using so it's ending up as ascii with a double-byte degree symbol (just a guess).

Not a problem for the vast majority of users I'm sure, as FSX loads these flightplans fine.

B21

tim arnot


Tim. @TimArnot