Commit 26f17682 authored by catch's avatar catch
Browse files

Issue #847608 by mikl: Fixed Use ellipsis character (…) instead of three dots (...).

parent a74ffedc
......@@ -321,7 +321,7 @@ function truncate_utf8($string, $max_length, $wordsafe = FALSE, $add_ellipsis =
if ($add_ellipsis) {
// Truncate ellipsis in case $max_length is small.
$ellipsis = drupal_substr(t('...'), 0, $max_length);
$ellipsis = drupal_substr(t(''), 0, $max_length);
$max_length -= drupal_strlen($ellipsis);
$max_length = max($max_length, 0);
}
......@@ -349,6 +349,9 @@ function truncate_utf8($string, $max_length, $wordsafe = FALSE, $add_ellipsis =
}
if ($add_ellipsis) {
// If we're adding an ellipsis, remove any trailing periods.
$string = rtrim($string, '.');
$string .= $ellipsis;
}
......
......@@ -227,6 +227,9 @@ class DrupalHtmlToTextTestCase extends DrupalWebTestCase {
'<html>Drupal</html>' => "Drupal\n",
// @todo Perhaps the contents of <script> tags should be dropped.
'<script type="text/javascript">Drupal</script>' => "Drupal\n",
// A couple of tests for Unicode characters.
'<q>I <em>will</em> be back…</q>' => "I /will/ be back…\n",
'FrançAIS is ÜBER-åwesome' => "FrançAIS is ÜBER-åwesome\n",
);
foreach ($tests as $html => $text) {
......
......@@ -236,47 +236,50 @@ class UnicodeUnitTest extends DrupalWebTestCase {
// Test non-wordsafe, ellipsis cases.
$non_wordsafe_ellipsis_cases = array(
array('frànçAIS is über-åwesome', 24, 'frànçAIS is über-åwesome'),
array('frànçAIS is über-åwesome', 23, 'frànçAIS is über-åwe...'),
array('frànçAIS is über-åwesome', 17, 'frànçAIS is üb...'),
array('frànçAIS is über-åwesome', 23, 'frànçAIS is über-åweso…'),
array('frànçAIS is über-åwesome', 17, 'frànçAIS is über…'),
);
$this->runTruncateTests($non_wordsafe_ellipsis_cases, FALSE, TRUE);
// Test wordsafe, ellipsis cases.
$wordsafe_ellipsis_cases = array(
array('123', 1, '.'),
array('123', 2, '..'),
array('123', 1, ''),
array('123', 2, '1…'),
array('123', 3, '123'),
array('1234', 3, '...'),
array('1234', 3, '12…'),
array('1234567890', 10, '1234567890'),
array('12345678901', 10, '1234567...'),
array('12345678901', 10, '123456789…'),
array('12345678901', 11, '12345678901'),
array('123456789012', 11, '12345678...'),
array('123456789012', 11, '1234567890…'),
array('12345 7890', 10, '12345 7890'),
array('12345 7890', 9, '12345...'),
array('12345 7890', 9, '12345'),
array('123 567 90', 10, '123 567 90'),
array('123 567 901', 10, '123 567...'),
array('123 567 901', 10, '123 567'),
array('Stop. Hammertime.', 17, 'Stop. Hammertime.'),
array('Stop. Hammertime.', 16, 'Stop....'),
array('Stop. Hammertime.', 16, 'Stop'),
array('frànçAIS is über-åwesome', 24, 'frànçAIS is über-åwesome'),
array('frànçAIS is über-åwesome', 23, 'frànçAIS is über...'),
array('frànçAIS is über-åwesome', 17, 'frànçAIS is...'),
array('frànçAIS is über-åwesome', 23, 'frànçAIS is über'),
array('frànçAIS is über-åwesome', 17, 'frànçAIS is über…'),
array('¿Dónde está el niño?', 20, '¿Dónde está el niño?'),
array('¿Dónde está el niño?', 19, '¿Dónde está el...'),
array('¿Dónde está el niño?', 15, '¿Dónde está...'),
array('¿Dónde está el niño?', 10, '¿Dónde...'),
array('¿Dónde está el niño?', 19, '¿Dónde está el'),
array('¿Dónde está el niño?', 13, '¿Dónde está'),
array('¿Dónde está el niño?', 10, '¿Dónde'),
array('Help! Help! Help!', 17, 'Help! Help! Help!'),
array('Help! Help! Help!', 16, 'Help! Help!...'),
array('Help! Help! Help!', 15, 'Help! Help!...'),
array('Help! Help! Help!', 14, 'Help! Help!...'),
array('Help! Help! Help!', 13, 'Help! Help...'),
array('Help! Help! Help!', 12, 'Help!...'),
array('Help! Help! Help!', 11, 'Help!...'),
array('Help! Help! Help!', 10, 'Help!...'),
array('Help! Help! Help!', 9, 'Help!...'),
array('Help! Help! Help!', 8, 'Help!...'),
array('Help! Help! Help!', 7, 'Help...'),
array('Help! Help! Help!', 6, 'Hel...'),
array('Help! Help! Help!', 5, 'He...'),
array('Help! Help! Help!', 16, 'Help! Help!…'),
array('Help! Help! Help!', 15, 'Help! Help!…'),
array('Help! Help! Help!', 14, 'Help! Help!…'),
array('Help! Help! Help!', 13, 'Help! Help!…'),
array('Help! Help! Help!', 12, 'Help! Help!…'),
array('Help! Help! Help!', 11, 'Help! Help…'),
array('Help! Help! Help!', 10, 'Help!…'),
array('Help! Help! Help!', 9, 'Help!…'),
array('Help! Help! Help!', 8, 'Help!…'),
array('Help! Help! Help!', 7, 'Help!…'),
array('Help! Help! Help!', 6, 'Help!…'),
array('Help! Help! Help!', 5, 'Help…'),
array('Help! Help! Help!', 4, 'Hel…'),
array('Help! Help! Help!', 3, 'He…'),
array('Help! Help! Help!', 2, 'H…'),
);
$this->runTruncateTests($wordsafe_ellipsis_cases, TRUE, TRUE);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment