Page MenuHomePhabricator

D10390.id25006.diff
No OneTemporary

D10390.id25006.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -427,7 +427,6 @@
'phutil_utf8_hard_wrap' => 'utils/utf8.php',
'phutil_utf8_hard_wrap_html' => 'utils/utf8.php',
'phutil_utf8_is_combining_character' => 'utils/utf8.php',
- 'phutil_utf8_shorten' => 'utils/utf8.php',
'phutil_utf8_strlen' => 'utils/utf8.php',
'phutil_utf8_strtolower' => 'utils/utf8.php',
'phutil_utf8_strtoupper' => 'utils/utf8.php',
diff --git a/src/filesystem/linesofalarge/__tests__/LinesOfALargeExecFutureTestCase.php b/src/filesystem/linesofalarge/__tests__/LinesOfALargeExecFutureTestCase.php
--- a/src/filesystem/linesofalarge/__tests__/LinesOfALargeExecFutureTestCase.php
+++ b/src/filesystem/linesofalarge/__tests__/LinesOfALargeExecFutureTestCase.php
@@ -54,7 +54,9 @@
$this->assertEqual(
$read,
$lines,
- 'Write: '.phutil_utf8_shorten($write, 32));
+ 'Write: '.id(new PhutilUTF8StringTruncator())
+ ->setMaximumGlyphs(32)
+ ->truncateString($write));
}
}
diff --git a/src/filesystem/linesofalarge/__tests__/LinesOfALargeFileTestCase.php b/src/filesystem/linesofalarge/__tests__/LinesOfALargeFileTestCase.php
--- a/src/filesystem/linesofalarge/__tests__/LinesOfALargeFileTestCase.php
+++ b/src/filesystem/linesofalarge/__tests__/LinesOfALargeFileTestCase.php
@@ -98,7 +98,9 @@
$this->assertEqual(
$read,
$lines,
- 'Write: '.phutil_utf8_shorten($write, 32));
+ 'Write: '.id(new PhutilUTF8StringTruncator())
+ ->setMaximumGlyphs(32)
+ ->truncateString($write));
}
public function allowCatsOnly($line) {
@@ -122,7 +124,9 @@
$this->assertEqual(
$read,
$lines,
- 'Write: '.phutil_utf8_shorten($write, 32));
+ 'Write: '.id(new PhutilUTF8StringTruncator())
+ ->setMaximumGlyphs(32)
+ ->truncateString($write));
}
}
diff --git a/src/future/http/status/HTTPFutureHTTPResponseStatus.php b/src/future/http/status/HTTPFutureHTTPResponseStatus.php
--- a/src/future/http/status/HTTPFutureHTTPResponseStatus.php
+++ b/src/future/http/status/HTTPFutureHTTPResponseStatus.php
@@ -11,7 +11,7 @@
array $headers,
$expect = null) {
- // NOTE: Avoiding phutil_utf8_shorten() here because this isn't lazy
+ // NOTE: Avoiding PhutilUTF8StringTruncator here because this isn't lazy
// and responses may be large.
if (strlen($body) > 512) {
$excerpt = substr($body, 0, 512).'...';
diff --git a/src/markup/engine/remarkup/blockrule/PhutilRemarkupTableBlockRule.php b/src/markup/engine/remarkup/blockrule/PhutilRemarkupTableBlockRule.php
--- a/src/markup/engine/remarkup/blockrule/PhutilRemarkupTableBlockRule.php
+++ b/src/markup/engine/remarkup/blockrule/PhutilRemarkupTableBlockRule.php
@@ -93,7 +93,9 @@
$message = sprintf(
'%s near: %s',
$message,
- phutil_utf8_shorten($near, 32000));
+ id(new PhutilUTF8StringTruncator())
+ ->setMaximumGlyphs(32000)
+ ->truncateString($near));
if ($this->getEngine()->isTextMode()) {
return '('.$message.')';
diff --git a/src/readableserializer/PhutilReadableSerializer.php b/src/readableserializer/PhutilReadableSerializer.php
--- a/src/readableserializer/PhutilReadableSerializer.php
+++ b/src/readableserializer/PhutilReadableSerializer.php
@@ -62,7 +62,7 @@
}
return $str;
} else {
- // NOTE: Avoid phutil_utf8_shorten() here since the data may not be
+ // NOTE: Avoid PhutilUTF8StringTruncator here since the data may not be
// UTF8 anyway, it's slow for large inputs, and it might not be loaded
// yet.
$limit = 1024;
diff --git a/src/utils/utf8.php b/src/utils/utf8.php
--- a/src/utils/utf8.php
+++ b/src/utils/utf8.php
@@ -399,25 +399,6 @@
/**
- * Shorten a string to provide a summary, respecting UTF-8 characters.
- *
- * This function is deprecated; use @{class:PhutilUTF8StringTruncator} instead.
- *
- * @param string UTF-8 string to shorten.
- * @param int Maximum length of the result.
- * @param string If the string is shortened, add this at the end. Defaults to
- * horizontal ellipsis.
- * @return string A string with no more than the specified character length.
- */
-function phutil_utf8_shorten($string, $length, $terminal = "\xE2\x80\xA6") {
- return id(new PhutilUTF8StringTruncator())
- ->setMaximumGlyphs($length)
- ->setTerminator($terminal)
- ->truncateString($string);
-}
-
-
-/**
* Hard-wrap a block of UTF-8 text with embedded HTML tags and entities.
*
* @param string An HTML string with tags and entities.

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 11, 12:54 AM (1 d, 4 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7485925
Default Alt Text
D10390.id25006.diff (4 KB)

Event Timeline