schars

Small library for working with chars in Haxe
https://github.com/selibs/schars

To install, run:

haxelib install schars 0.1.0 

See using Haxelib in Haxelib documentation for more information.

README.md

schars

Small Haxe library for working with Unicode characters as code points.

s.Char is an Int abstract with helpers for letters, digits, and case checks. s.CharArray converts a string to an array of Char without splitting UTF-16 surrogate pairs.

Unicode data is generated from UnicodeData.txt 17.0.0.

Usage

import s.Char;
import s.CharArray;

class Main {
	static function main() {
		var c:Char = "я";

		trace(c.isAlpha()); // true
		trace(c.isLower()); // true
		trace(c.toUpper()); // "Я"

		var chars:CharArray = "A𐐨۵中";
		trace(chars.length); // 4
		trace(chars.toString()); // A𐐨۵中
	}
}

API

  • Create Char from Int or String.
  • toString() converts a code point back to a string.
  • isAlpha(), isLetter(), isDigit(), isUpper(), isLower().
  • toUpper(), toLower().
  • next(), previous().
  • CharArray converts String to Array<Char> and back.

Char represents one Unicode code point, not a grapheme cluster.

Tests

haxe tests.hxml
Contributors
smoothie
Version
0.1.0
Published
3 months ago
License
Apache

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

⌂