]> git.proxmox.com Git - pve-common.git/commit
tools: allow to force UTF-8 encoding for file_set_contents
authorLukas Wagner <l.wagner@proxmox.com>
Wed, 30 Aug 2023 12:37:52 +0000 (14:37 +0200)
committerFiona Ebner <f.ebner@proxmox.com>
Mon, 11 Sep 2023 11:42:07 +0000 (13:42 +0200)
commit2943910ec3c92353622db4025fbdf3d8df12c964
treecde615fc16f1f687859173d7d58688cc3f83d184
parent41ed4396350713aa592aeb615a84363e2ce9298e
tools: allow to force UTF-8 encoding for file_set_contents

Rationale: This is used from cfs_write_file, which is now also used to
write utf8-encoded strings that come from Rust. If no encoding is
specified while writing the file, we run into problems with certain
special characters (e.g. 'ü').

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
[FG: use flag parameter instead of encoding as a string
     use stricter 'UTF-8' instaed of 'utf8' (see 'perldoc Enocode')]
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
[FE: implement changes suggested by Fabian
     move binmode call to where $fh is known to be set]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
src/PVE/Tools.pm