armbian - Chinese characters garbled due to lack of utf-8 encoding when mounting smb via cifs
问题
Issue
在 armbian(armv7) 中使用 mount - t cifs 默认不使用 utf-8 编码,这导致客户端使用中文时会出现乱码
这可能是一个 BUG,在debian(x64)中并未出现这个情况。
下图展示了通过 mount - t cifs 挂载 smb 是否添加参数 iocharset=utf8 的区别
In armbian (armv7), when using mount -t cifs, utf-8 encoding is not used by default, resulting in garbled characters when Chinese characters are used by the client. This might be a BUG as it is not observed in debian (x64).
The following image shows the difference between mounting smb using mount -t cifs with and without the iocharset=utf8 parameter:
I have no experience in project development, but with the help of chatgpt, I noticed that modifying lines 60-71 in the codebase [CasaOS]/service/connections.go can address this issue:
Modify fmt.Sprintf("username=%s,password=%s", username, password) to fmt.Sprintf("username=%s,password=%s,iocharset=utf8", username, password) to resolve the issue.
I believe this solution is feasible because most systems support utf-8, and most operating systems use utf-8 as the default encoding for cifs. Modifying this part of the code should not cause issues for other users.
[Armbian-unofficial 24.5.0-trunk Bullseye \l Bit:32 Mem:988M Core:4 Linux onecloud 6.6.32-current-meson #1 SMP Sat May 25 14:22:56 UTC 2024 armv7l GNU/Linux]
armbian 中通过 cifs 挂载 smb 默认不使用 utf-8 导致中文乱码
armbian - Chinese characters garbled due to lack of utf-8 encoding when mounting smb via cifs
问题
Issue
在 armbian(armv7) 中使用 mount - t cifs 默认不使用 utf-8 编码,这导致客户端使用中文时会出现乱码 这可能是一个 BUG,在debian(x64)中并未出现这个情况。 下图展示了通过 mount - t cifs 挂载 smb 是否添加参数 iocharset=utf8 的区别
In armbian (armv7), when using mount -t cifs, utf-8 encoding is not used by default, resulting in garbled characters when Chinese characters are used by the client. This might be a BUG as it is not observed in debian (x64). The following image shows the difference between mounting smb using mount -t cifs with and without the iocharset=utf8 parameter:
解决方案
Solution
本人无项目开发经验,但是在 chatgpt 的帮助下,注意到可以通过修改代码库中
[CasaOS]/service/connections.go
的第60-71行I have no experience in project development, but with the help of chatgpt, I noticed that modifying lines 60-71 in the codebase [CasaOS]/service/connections.go can address this issue:
其中的
fmt.Sprintf("username=%s,password=%s", username, password)
修改为fmt.Sprintf("username=%s,password=%s,iocharset=utf8", username, password)
解决。Modify fmt.Sprintf("username=%s,password=%s", username, password) to fmt.Sprintf("username=%s,password=%s,iocharset=utf8", username, password) to resolve the issue.
解决方案可行性
Feasibility of Solution
个人认为该解决方案是可行的,因为大多数的系统是支持 utf-8 的而且大多数操作系统的 cifs 默认编码采用的是 utf-8,修改该部分代码不会导致其他人的使用出现问题
I believe this solution is feasible because most systems support utf-8, and most operating systems use utf-8 as the default encoding for cifs. Modifying this part of the code should not cause issues for other users.