Skip to content

PawnPlus v1.5

Latest
Compare
Choose a tag to compare
@IS4Code IS4Code released this 09 Aug 13:44

Locales

Locales and locale-based operations now play a much integral role in the plugin. See here for a more comprehensive guide of how locales are configured and used. Main changes:

  • A custom format of the locale name is now used, allowing to specify the encoding and other parameters in addition to the locale name. This allows using Unicode-based locales as well as tweak details of how other operations behave, such as the interpretation of characters outside the ANSI range, the fallback character used when no mapping is available, and so on.
  • In addition, the format supports |-separated alternatives, to form a single locale name that could be used on multiple platforms (e.g. both Windows and Linux) to select the appropriate supported locale.
  • This form of locale name can now be used in existing functions such as str_to_lower/str_to_upper, as well as new functions like str_count_chars or str_collation_key. In practice, this means that different locale-based rules could be applied to individual calls, without using pp_locale to modify the global locale.

String formatting and conversions

Thanks to the new locale features, additional enhancements for string formatting and conversions were possible:

  • The str_convert function can be used to convert from one encoding into another. This can be used to convert an ANSI-encoded string into Unicode, or vice versa.
  • str_format and other formatting functions now support changing the locale mid-string, in the form of {$enc:identifier}, applying to the format specifiers that follow it. This can be used to set the default number formatting rules, to perform automatic str_convert for strings, etc.
  • New format selectors were added: %m (monetary value) and %t (time), both using locale-based output format. In addition, x now supports floats and produces a hex-float when used on a known float value.

Regular expressions

Existing regular expression capabilities were also enhanced with locale support, as well as as a new pattern-matching engine: Lex, inspired by Lua.

  • The locale can be specified at the beginning of any pattern by using the syntax ($identifier). This affects how the pattern is parsed, as well as what rules are used for matching the pattern.
  • Support for classes and collations has been improved, taking use of locale-defined ones when possible.
  • A new option regex_percents can be used, switching from \ to % as the escape character for any pattern or replacement string.
  • The regex_lex options can be used, setting the alternative Lex engine and pattern syntax. This has several differences (from both usual patterns and Lua):
    • \ is still used as the primary escape character, unless regex_percents is used.
    • Character classes must be used as \a, \g, \c, \p, \l, \u, and \x. No other locale-defined classes are possible.
    • Collation-based and case-insensitive matching is possible through the usual flags, unlike in Lua.

Other

  • The project was updated to C++14 and will likely remain at that version for a long time.
  • Added pp_num_amx_vars to obtain the number of Var: instances.
  • Dynamically calling native functions on the main thread protects against non-critical system errors/signals raised in them.
  • Added a few missing functions to the C API, mainly for memory and containers.
  • Using pp_locale_name on Windows no longer returns empty string after pp_locale("") and instead obtains the actual name of the system locale.