Changeset View
Changeset View
Standalone View
Standalone View
src/xsprintf/PhutilTerminalString.php
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | public static function escapeStringValue($value, $allow_whitespace) { | ||||
$value = str_replace(array_keys($map), array_values($map), $value); | $value = str_replace(array_keys($map), array_values($map), $value); | ||||
// In this mode, we additionally escape any <CR> which is not immediately | // In this mode, we additionally escape any <CR> which is not immediately | ||||
// followed by <LF>. | // followed by <LF>. | ||||
if ($allow_whitespace) { | if ($allow_whitespace) { | ||||
$value = preg_replace('/\r(?!\n)/', '<CR>', $value); | $value = preg_replace('/\r(?!\n)/', '<CR>', $value); | ||||
} | } | ||||
// See T13209. If we print certain invalid unicode byte sequences to the | |||||
// terminal under "cmd.exe", the entire string is silently dropped. Avoid | |||||
// printing invalid sequences. | |||||
if (phutil_is_windows()) { | |||||
$value = phutil_utf8ize($value); | |||||
} | |||||
return $value; | return $value; | ||||
} | } | ||||
} | } |