Dateien

> > CS2D > Lua Scripts > [EngiN33R] UTF-8 Wrapper Library
DateiübersichtCS2D-ÜbersichtLua Scripts-Übersicht

Englisch [EngiN33R] UTF-8 Wrapper Library >

22 Kommentare2 kb, 582 Downloads

alt [EngiN33R] UTF-8 Wrapper Library

EngiN33R
Moderator Off Offline

This is an official tiny wrapper library that helps you forget about UTF-8 conversions in the new CS2D versions. The library replaces the msg, msg2, print and parse functions to always use UTF-8. The library has a safeguard against being loaded multiple times, so it should be safe to include in your mod or script without additional considerations.

When using this library for UTF-8 strings in your code, make sure to save your .lua files as UTF-8 without BOM!

In case you need raw access to UTF-8 helper functions, the library provides the following:

• utf8.codepoint(char) [number] - get the Unicode codepoint of the given character.
• utf8.encode(char) [string] - get the UTF-8 representation of a single character.
• utf8.convert(str) [string] - get a CS2D-ready UTF-8 representation of the given string.

After loading this library, UTF-8 conversion works as follows:

• utf8.convert("欢迎来到CS2D") gives
UTF-8:xE6xACxA2xE8xBFx8ExE6x9DxA5xE5x88xB0x43x53x32x44

• utf8.convert("Привет CS2D!") gives
UTF-8:xD0x9FxD1x80xD0xB8xD0xB2xD0xB5xD1x82x20x43x53x32x44x21
1× editiert, zuletzt 05.12.17 21:17:54
Zugelassen von SQ

Download Download

2 kb, 582 Downloads

Kommentare

22 Kommentare
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

Logge dich ein!

Du musst dich einloggen, um selber Kommentare verfassen zu können!Einloggen

alt

Infinite Rain
Reviewer Off Offline

Good work. But why don't you use a standard Lua way of making a module? I.E. No global declarations and one return. If you do it that way, then there's no reason to implement a safeguard, as "require" function already has a safeguard implemented.
Ich mag es!

alt

SQ
Moderator Off Offline

This deserves a like.
Ich mag es!
Zum Anfang Vorherige 1 2 Nächste Zum Anfang