In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to make CodeIgniter's ellipsize () support Chinese truncation". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to make CodeIgniter's ellipsize () support Chinese truncation".
CodeIgniter's Text Helper has an ellipsize () method that is useful for filtering HTML tags and truncating text. However, it does not support Chinese very well, and garbled codes appear when used in Chinese.
The following netizens have modified function ellipsize () to make it support Chinese:
In CI 2.1.3, modify the ci_2.1.3\ system\ helpers\ text_helper.php file
Function ellipsize ($codepage = 'UTF-8', $str, $max_length, $position = 1, $ellipsis ='...') {/ / Strip tags $str = trim (strip_tags ($str)); / / Is the string long enough to ellipsize? If (mb_strlen ($str, $codepage) 1)? 1: $position; if ($position = 1) {$end = mb_substr ($str, 0,-($max_length-mb_strlen ($beg, $codepage), $codepage);} else {$end = mb_substr ($str,-($max_length-mb_strlen ($beg, $codepage), $max_length, $codepage);} return $beg.$ellipsis.$end;}
This code mainly replaces substr and strlen with mb_substr and mb_strlen, so it can support Chinese truncation very well.
The above is all the contents of the article "how to make CodeIgniter's ellipsize () support Chinese truncation". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.