text s: "Hello \xD1\xBEorld!" // equals "Hello Ѿorld!"Here \x is followed by hexadecimal code of the 8-bit character sequence. Codes D1 and BE ("\xD1\xBE") combined are the UTF-8 code for the letter Ѿ. See the reference page for more information about escape (backslash) sequences.
The unicode support was made possible by a big refactoring under the hood. I started using own string type instead of native string. Meanscript’s string type (MSText) uses internally an integer array to save text in UTF-8 format. This helps also to minimize dependencies to external libraries. The plan is to use native strings (e.g. java.lang.String) only in public interfaces (API).
More examples at Meanscript's GitHub page.
You can define the 64-bit numbers in a script
int64 bigInteger: 1234567891234; // 64-bit integer float64 bigFloat: 12.123456789; // 64-bit floating-point numberor source code
MSBuilder builder ("example"); builder.addInt64("bigInteger", 1234567891234); builder.addFloat64("bigInteger", 12.123456789);Variables in Meanscript are stored in a 32-bit integer array, so floating-point numbers must be converted to integers to store them in Meanscript. For 64-bits, the conversion is wrapped inside a macro FLOAT64_TO_INT64_FORMAT(f) to make implementation for each supported language. In C++ the conversion can be done efficiently with some casting trickery:
#define FLOAT64_TO_INT64_FORMAT(f) ((int64_t&)(*(&f)))In Java there’s a function for that in Double library
#define FLOAT64_TO_INT64_FORMAT(f) Double.longBitsToDouble(f)After the conversion, the data can be stored to a 32-bit integer array by splitting 64-bit integer in half.
Conversions from integer to floating-point and back can vary according to environment, so there’s a unit tests that make sure the conversions are identical in all environments, e.g.
FLOAT64 f64 = -12.123456789; INT64 longBits = FLOAT64_TO_INT64_FORMAT(f64); TEST(longBits == -4600357519365344569l);
For more information check out GitHub's reference page.
In the future I try to make the code more robust and improve reporting, in addition to some UI issues. Maybe some day I make the code open source after I’ve cleaned up stuff that’s hard-coded for this web site!
|Copyright (C) 2021, Meanwhale||↑ top|