Jump to content
The simFlight Network Forums

LUA UTF-8 Encoding


Recommended Posts

Hi Pete

Is there a way of getting the FSUIPC embedded LUA to work in UTF-8 encoding? A Chinese LINDA user is experiencing errors when his system reads a LUA file on his system with UTF-8 set.

When a UTF-8 .lua file is loaded he gets this error:

[E] *** LUA Error: error loading module 'linda-cfg/system/config-sys' from file 'D:\Prepar3D v4\modules\linda-cfg/system/config-sys.lua':
D:\Prepar3D v4\modules\linda-cfg/system/config-sys.lua:1: unexpected symbol near '�'

I have had similar issues and have had to remove the additional bytes generated by UTF-8 using code.

Link to comment
Share on other sites

1 hour ago, Scotfleiger said:

Is there a way of getting the FSUIPC embedded LUA to work in UTF-8 encoding? A Chinese LINDA user is experiencing errors when his system reads a LUA file on his system with UTF-8 set.

It's the Lua interpreter itself which reads the files. FSUIPC just passes it the filepath.

The Visual Studio compiler options for character sets being used are 

Unicode, or
Mult-byte character set.

Now Unicode is a 16-bit charcter code system and I can't compile with that without losing cimpatibility with pretty much all the files used or accessed by FSUIPC. And it would mean a lot of code changes too as the two really are not compatible for most character or string based operations.

But I thought "UTF-8 was an 8bit character system with extensions by multiple bytes. Isn't that the same as "multi-byte character set"? I it needs Unicode then, sorry, there's no way without quite a major amount of error prone changes.

And do you know if the Lua interpreter is compatible in any case?  Are these 'unexpected symbols" actually withing code? 

Does the Lua compiler accept the input?

Pete

 

 

Link to comment
Share on other sites

Thank you Pete. I would not encourage a rebuild for this issue. The error is only triggered on a Win10 Chinese system when a "beta" UTF-8 button is ticked. The lua file being loaded (via the require command) is identical to my own copy and both are reported to be encoded in UTF-8 format (using Textwangler on my Mac). I can't explain why an English Win10 system should work fine and the Chinese one not. This is the only report of this problem and I don't intend taking it further at this time.

Link to comment
Share on other sites

1 hour ago, Scotfleiger said:

Thank you Pete. I would not encourage a rebuild for this issue.

Not just a rebuild, a substantail amount of changes, and all of them error prone. There's a lot ringing on one byte characters.

Quote

The error is only triggered on a Win10 Chinese system when a "beta" UTF-8 button is ticked. The lua file being loaded (via the require command) is identical to my own copy and both are reported to be encoded in UTF-8 format (using Textwangler on my Mac). I can't explain why an English Win10 system should work fine and the Chinese one not. This is the only report of this problem and I don't intend taking it further at this time.

It couldn't be due to something simpler like the numberic encoding (, and . inverted), could it?

Did he try compiling the Lua to see if that's accepted? Of course, if compiled Lua actually uses any real x86 machine code then it wouldn't work with a 64-bit FSIPC, but since Lua is really interpreted in any case Ione might expect that the interim language is a type of "P-code".

Pete

 

Link to comment
Share on other sites

   Sorry to interfere here guys,  but ( if i understood the problem correctly )  the behavior i am observing on my old system (FS 9 +Win 8.1) might provide some clues.  If i use Notepad to write a lua plugin,  and if i save it under Utf-8 codding  (  Notepad---Save as - Filename = blabla.lua ----  Save as type = All Files ----- Encoding = UTF-8 ) , then when the plug-in   is attempted to be run within flightsim ,  the build-in debugger reports " unexpected symbol after... " .    If i try to compile it (  luac - o   result.lua   blabla.lua ), then the compiler is the one  screaming out( " unexpected symbol .... ). The only way to run the  lua plug-in is when it is saved under ANSI Coding  - if that is all right ( I hope it is ).

Best Regards

  • Like 1
Link to comment
Share on other sites

26 minutes ago, Zlatko said:

If i try to compile it (  luac - o   result.lua   blabla.lua ), then the compiler is the one  screaming out( " unexpected symbol .... ).

So, it is the Lua language not accepting it.

I suspect other programming languages are similarly restricted. In fact I wonder if my FSUIPC source would compile if I saved the files in UTF-8.  I somehow doubt it. (No, i'm not going to try).

Pete

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.