When working with PHP, you may need to look up Unicode decomposition data for one character. This guide explains the operation, shows what its arguments mean, and uses three separate examples to make the result easier to understand.
Normalizer::getRawDecomposition: Raw decomposition is a low-level Unicode property, not a complete normalization workflow.
What Is Normalizer::getRawDecomposition in PHP?
Look up Unicode decomposition data for one character. Raw decomposition is a low-level Unicode property, not a complete normalization workflow.
Syntax:
Normalizer::getRawDecomposition(string $string, int $form = Normalizer::FORM_C): ?string
Parameters and return value: The signature above identifies the arguments and return type where the API has a single call. For topic guides, follow the sequence of calls in the examples. Always distinguish a returned value from an object or variable modified by reference.
Important: The input should represent a single Unicode code point. A null result can mean no decomposition mapping is available.
Example 1: Basic Usage
This example introduces the operation with a short and predictable input.
<?php
var_dump(Normalizer::getRawDecomposition("é"));
The code focuses on the main operation. Raw decomposition is a low-level Unicode property, not a complete normalization workflow.
Example 2: Another Case
Now compare a different input, locale, date, or option to see another part of the behavior.
<?php
var_dump(Normalizer::getRawDecomposition("A"));
What changes? The input should represent a single Unicode code point. A null result can mean no decomposition mapping is available.
Practical Example: Applying It in an Application
Use the following separate example as a starting point for a small application task. Check any extension or environment requirements below before running it.
<?php
$characters = ["é", "Å", "A"];
foreach ($characters as $character) {
var_dump(Normalizer::getRawDecomposition($character));
}
The practical example demonstrates how to apply this operation to multiple values, a reusable task, or a validated input. Raw decomposition is a low-level Unicode property, not a complete normalization workflow.
Important Behavior and Edge Cases
- Core behavior: Raw decomposition is a low-level Unicode property, not a complete normalization workflow.
- Inputs and results: The input should represent a single Unicode code point. A null result can mean no decomposition mapping is available.
- Alternatives: Normalizer::normalize() processes complete strings rather than reading one character mapping.
- Compatibility: The intl extension is required.
Comparison With Related Functions
| Function or Approach | When to Use It |
|---|---|
Normalizer::getRawDecomposition | Look up unicode decomposition data for one character. |
| Related PHP approach | Normalizer::normalize() processes complete strings rather than reading one character mapping. |
Common Beginner Mistakes
| Mistake | Correct Approach |
|---|---|
| Using an incorrect input or option | The input should represent a single Unicode code point. A null result can mean no decomposition mapping is available. |
| Confusing this API with a related operation | Normalizer::normalize() processes complete strings rather than reading one character mapping. |
| Assuming output is identical across environments | Check return values and required extensions or versions. The intl extension is required. |
Key Takeaways
- Normalizer::getRawDecomposition helps you look up Unicode decomposition data for one character.
- Raw decomposition is a low-level Unicode property, not a complete normalization workflow.
- The input should represent a single Unicode code point. A null result can mean no decomposition mapping is available.
Use Normalizer::getRawDecomposition when you need to look up Unicode decomposition data for one character. Start with the first example, compare the second, and adapt the practical example to your inputs. Confirm the return value and environment requirements before adding it to production code.