我试着得到“普吕芬”的速度长度。
示例:
#set ($data = "prüfen")
#set( $total_length = $data.length())
$total_length // Output is 6问:我想输出7(因为字符"ü“占2),如何获得长度的”普吕芬“的速度。
我也试过
#set( $len_of_data = $data.getBytes().length)
$len_of_data但什么都没起作用。
发布于 2017-07-26 21:49:25
这似乎是可行的:
#set ($data = "prüfen")
#set( $total_length = $data.getBytes('UTF-8').size())
$total_length一定要用input.encoding = UTF-8配置速度。
使用1.7+,您可以像调用列表一样调用数组上的size() (以及isEmpty()和get(int))。
https://stackoverflow.com/questions/45320389
复制相似问题