From 1cfab534727fb03ce9610db304a95dcdab9037f7 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 28 Apr 2018 01:26:32 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AC=B8=EC=9E=90=EC=97=B4=20=EC=9E=90?= =?UTF-8?q?=EB=A5=B4=EA=B8=B0=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sammo/StringUtil.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sammo/StringUtil.php b/src/sammo/StringUtil.php index 7b0ce9c2..30d4e9a8 100644 --- a/src/sammo/StringUtil.php +++ b/src/sammo/StringUtil.php @@ -27,6 +27,9 @@ class StringUtil $currentPos = 0; $currentWidth = 0; + $rawStart = 0; + $rawWidth = 0; + $strings = static::splitString($str); foreach($strings as $idx=>$char){ $charWidth = mb_strwidth($char, 'UTF-8'); @@ -34,10 +37,11 @@ class StringUtil break; } $currentPos += $charWidth; + $rawStart += strlen($char); } if($currentPos + $width >= $length){ - return substr($str, $currentPos); + return substr($str, $rawStart); } for($idx = $currentPos; $idx < count($strings); $idx++){ @@ -48,9 +52,10 @@ class StringUtil break; } $currentWidth += $charWidth; + $rawWidth += strlen($char); } - return substr($str, $currentPos, $currentWidth); + return substr($str, $rawStart, $rawWidth); } public static function cutStringForWidth(string $str, int $width, string $endFill='..')