|
| 1 | +<!-- |
| 2 | +SPDX-FileCopyrightText: (c) Respect Project Contributors |
| 3 | +SPDX-License-Identifier: ISC |
| 4 | +SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com> |
| 5 | +--> |
| 6 | + |
| 7 | +# UppercaseFormatter |
| 8 | + |
| 9 | +The `UppercaseFormatter` converts strings to uppercase with proper UTF-8 character support for international text. |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +### Basic Usage |
| 14 | + |
| 15 | +```php |
| 16 | +use Respect\StringFormatter\UppercaseFormatter; |
| 17 | + |
| 18 | +$formatter = new UppercaseFormatter(); |
| 19 | + |
| 20 | +echo $formatter->format('hello world'); |
| 21 | +// Outputs: "HELLO WORLD" |
| 22 | +``` |
| 23 | + |
| 24 | +### Unicode Characters |
| 25 | + |
| 26 | +```php |
| 27 | +use Respect\StringFormatter\UppercaseFormatter; |
| 28 | + |
| 29 | +$formatter = new UppercaseFormatter(); |
| 30 | + |
| 31 | +echo $formatter->format('café français'); |
| 32 | +// Outputs: "CAFÉ FRANÇAIS" |
| 33 | + |
| 34 | +echo $formatter->format('こんにちは'); |
| 35 | +// Outputs: "コンニチハ" |
| 36 | +``` |
| 37 | + |
| 38 | +### Mixed Content |
| 39 | + |
| 40 | +```php |
| 41 | +use Respect\StringFormatter\UppercaseFormatter; |
| 42 | + |
| 43 | +$formatter = new UppercaseFormatter(); |
| 44 | + |
| 45 | +echo $formatter->format('Hello World 😊'); |
| 46 | +// Outputs: "HELLO WORLD 😊" |
| 47 | +``` |
| 48 | + |
| 49 | +## API |
| 50 | + |
| 51 | +### `UppercaseFormatter::__construct` |
| 52 | + |
| 53 | +- `__construct()` |
| 54 | + |
| 55 | +Creates a new uppercase formatter instance. |
| 56 | + |
| 57 | +### `format` |
| 58 | + |
| 59 | +- `format(string $input): string` |
| 60 | + |
| 61 | +Converts the input string to uppercase using UTF-8 aware conversion. |
| 62 | + |
| 63 | +**Parameters:** |
| 64 | + |
| 65 | +- `$input`: The string to convert to uppercase |
| 66 | + |
| 67 | +**Returns:** The uppercase string |
| 68 | + |
| 69 | +## Examples |
| 70 | + |
| 71 | +| Input | Output | Description | |
| 72 | +| ------------ | ------------ | --------------------------------------- | |
| 73 | +| `hello` | `HELLO` | Simple ASCII text | |
| 74 | +| `café` | `CAFÉ` | Latin characters with accents | |
| 75 | +| `привет` | `ПРИВЕТ` | Cyrillic text | |
| 76 | +| `こんにちは` | `コンニチハ` | Japanese hiragana converted to katakana | |
| 77 | +| `Hello 😊` | `HELLO 😊` | Text with emoji | |
| 78 | +| `éîôû` | `ÉÎÔÛ` | Multiple accented characters | |
| 79 | + |
| 80 | +## Notes |
| 81 | + |
| 82 | +- Uses `mb_strtoupper()` for proper Unicode handling |
| 83 | +- Preserves accent marks and diacritical marks |
| 84 | +- Works with all Unicode scripts (Latin, Cyrillic, Greek, CJK, etc.) |
| 85 | +- Emoji and special symbols are preserved unchanged |
| 86 | +- Combining diacritics are properly handled |
| 87 | +- Numbers and special characters remain unchanged |
| 88 | +- Empty strings return empty strings |
0 commit comments