PHP code example of rayblair / unicode

1. Go to this page and download the library: Download rayblair/unicode library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rayblair / unicode example snippets


use Rayblair\Unicode\Unicode;

echo Unicode::HYPHEN_MINUS; // Outputs: -

$mappings = [
    Unicode::EN_DASH => Unicode::HYPHEN_MINUS,
    Unicode::EM_DASH => Unicode::HYPHEN_MINUS,
];

use Rayblair\Unicode\Unicode;

// Get single Unicode constant
print_r(Unicode::HYPHEN_MINUS); // Outputs: -

// Get all Unicode constants
print_r(Unicode::getAll());

// Get first 10 Unicode constants
print_r(Unicode::get(10));

// Get Unicode characters within a specific range
print_r(Unicode::range('0041', '0044'));

// Convert UTF-8 characters into Unicode escape sequences
echo Unicode::escape('A'); // Outputs \u0041

print_r(Unicode::getAll());

Array
(
    [LATIN_CAPITAL_LETTER_A] => A
    [LATIN_CAPITAL_LETTER_B] => B
    [LATIN_SMALL_LETTER_A] => a
)

print_r(Unicode::get(5));

print_r(Unicode::range('0041', '0044'));

Array
(
    [LATIN_CAPITAL_LETTER_A] => A
    [LATIN_CAPITAL_LETTER_B] => B
    [LATIN_CAPITAL_LETTER_C] => C
    [LATIN_CAPITAL_LETTER_D] => D
)

echo Unicode::escape('Hello, 😊!'); // Outputs: \u0048\u0065\u006c\u006c\u006f, \u1F60A!