Prev IsPhonetic |
ExcelExplorer Manual |
Next EEDataRichText class |
 |
(ExcelExplorer 4.0)
Returns phonetic data if any.
false array(EEDataPhonetic) Phonetic( )
Parameters
- None
Description
Asian phonetic text (ruby text) is the text that appears in the immediate vicinity of another text (base text).
It used as annotation or a pronunciation guide associated with base text.
Ruby text can refer to single characters, groups of characters, or entire words.
If you do not need to read ruby text you can still use
methods like UTF8() that will ignore phonetic data and works with the whole string.
Note that this method can returns FALSE in the following cases:
- Cell contains non-text value.
- String contains no asian phonetic.
- Erroneous data stored in the Excel file.
You should always check if returned value is valid array (not a FALSE) before accessing its elements (EEDataPhonetic objects).
Examples of the ruby text:
 |
 |
 |
| Fig. 1 Ruby applied to the English text |
Fig. 2 Japanese word Tokyo with added hiragana (hiragana refer to the entire word and centered) |
Fig. 3 Japanese word Tokyo with added hiragana (hiragana refer to the characters and left-aligned) |
This method returns array of EEDataPhonetic objects.
Each element represents a part of the text. Each part can have ruby text applied or not.
So, for the examples above the returning value will be:
- Fig. 1 - array of 1 element of EEDataPhonetic object.
Object contains base text "WWW" and the ruby text "World Wide Web" applied to it.
- Fig. 2 - the same, only base text and ruby text are different.
- Fig. 3 - array of the 2 elements of EEDataPhonetic objects.
First object contains first character of the base text with two hiragana characters as ruby text.
The second one contains second character of the base text with rest of hiragana characters as ruby text.
If ruby text applied only to a some portion of the string then in returned array will present some objects that not contains corresponding ruby text.
For more detailed information how to obtain additional info about phonetic (used fonts, rich text data for the base text, phonetic alignment, etc.) refer to the EEDataPhonetic methods description.
Information about how to display ruby text in the HTML documents available at W3C site (http://www.w3.org/) at this link: http://www.w3.org/TR/WD-ruby.
Print asian phonetic in HTML format (output generated using string from Fig. 1)
<?php
// Assume that string stored in the first worksheet, A1 cell
if( ($ph = $ee->Cell(0,0,0)->Data()->Phonetic()) ) {
echo count($ph)." phonetic part(s) found\n";
for( $i=0; $i<count($ph); $i++ ) {
if( $ph[$i]->Phonetic() ) {
// open HTML tag
echo '<ruby>';
// print base text
echo $ph[$i]->Data()->HTML();
echo '<rp>(</rp><rt>';
// print ruby text
echo $ph[$i]->Phonetic()->HTML();
// close HTML tag
print '</rt><rp>)</rp></ruby>';
} else {
echo $ph[$i]->Data()->HTML();
}
}
} else {
echo "No phonetic data found\n";
}
?>
Will output: 1 phonetic part(s) found
<ruby>WWW<rp>(</rp><rt>World Wide Web</rt><rp>)</rp></ruby>
|