From dea0fc522840cb5a1b55f8c2e56d110c1cc5e7b7 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Thu, 17 Mar 2016 00:11:31 +0100 Subject: [PATCH] Initial commit --- .gitignore | 1 + README.md | 22 ++++++++++++++++++++++ composer.json | 18 ++++++++++++++++++ examples/unicode.php | 13 +++++++++++++ lib/unicode.php | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 composer.json create mode 100644 examples/unicode.php create mode 100644 lib/unicode.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..22d0d82 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vendor diff --git a/README.md b/README.md new file mode 100644 index 0000000..f256bbd --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +noccylabs/unicode +================= + +This library adds support for writing unicode characters to the console. It will +register a number of global functions for this purpose: + + * `uchr($numeric)` - Returns the unicode character matching the numeric argument. + * `uprintf($fmt, $arg..)` - A wrapper for `printf` that enables `\u` to embed + unicode strings. + * `usprintf($fmt, $arg..)` - A wrapper like `uprintf` but for `sprintf`. + + +## Examples + +To output a specific UTF-8 glyph: + + echo uchr(0x1000) + +The same thing in a printf fashion: + + uprintf("Unicode glyph x1000: \u1000"); + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..dc653ee --- /dev/null +++ b/composer.json @@ -0,0 +1,18 @@ +{ + "name": "noccylabs/unicode", + "description": "Functions to output unicode characters to the console", + "type": "library", + "license": "GPL-3.0", + "authors": [ + { + "name": "Christopher Vagnetoft", + "email": "cvagnetoft@gmail.com" + } + ], + "require": {}, + "autoload": { + "files": [ + "lib/unicode.php" + ] + } +} diff --git a/examples/unicode.php b/examples/unicode.php new file mode 100644 index 0000000..feb9877 --- /dev/null +++ b/examples/unicode.php @@ -0,0 +1,13 @@ +