对于Layui时间与分页组件乱码处理

问题描述

使用layui分页与时间等组件出现乱码问题,如下图所示


解决方案

将miniTab.js,layui.js中将中文替换为Unicode。我是使用python代码完成替换,先放一个txt文件里

点击查看

def change_chinese_unicoding(strs):
strs2 = ""
for i in range(len(strs)):
new_str = strs[i]
# 修复数字字符被判定为中文抓unicode的BUG
if new_str.isnumeric():
strs2 += new_str
continue
# 判断是否为中文
if '\u4e00' <= new_str <= '\u9fa5':
new_str = new_str.encode('unicode-escape').decode()
strs2 += new_str
return strs2

if name == 'main':
filepath = "F:\Desktop\txt.txt"
with open(filepath, 'r', encoding='utf-8') as f:
data = f.read()
f.close()
print(data)
with open(filepath, 'w', encoding='utf-8') as f:
data = change_chinese_unicoding(data)
f.write(data)
f.close()
print("OK")

posted @ 2023-02-28 10:46  冥天肝  阅读(490)  评论(0编辑  收藏  举报