stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

Styles.csv encoding utf-8-sig, webui-user.bat change to script directory

Open w-e-w opened this issue 1 year ago • 1 comments

change styles.csv encoding from utf8 to utf-8-sig

this allows for better compatibility for some programs such as Excel reason provided in next comment

changing work directory to script directory for webui-user.bat

so that the script can be executed via terminal without changing the work directory first

otherwise when the script tries to call webui.bat it may not find the file

this should be safe to merge as the current has a built-in auto update system will stash the changes then restore it after pull so this change should not overwriting existing webui-user.bat

this should only affect new downloads

w-e-w avatar Oct 17 '22 06:10 w-e-w

Reason for using utf-8-sig over utf8 for styles.csv

Currently the web UI allows users to save Styles and Styles_Name to styles.csv, and it allows the use of non-english characters, such as Chinese Japanese this is working without issue

but if the user were to open the styles.csv in an external software such as Excel the text will be displayed as garbled

screenshot below

this can be fixed by adding the BOM to the styles.csv

Backwards compatibility with existing styles.csv

No issue

utf-8-sig allows the read and writing of BOM and non-BOM files

conversely utf8 can only read non-BOM files trying to read a file with file with BOM will result in an error

No issue with writing existing non-BOM styles.csv withutf-8-sig, when writing to a existing non-BOM files, the file will be automatically converted to BOM

read utf8 read utf-8-sig write utf8 write utf-8-sig Excel
utf-8 file works works works convert file to utf-8-bom error
utf-8-bom file error works untested works works

example with Excel opening a non-BOM and BOM csv file

image opening same file but one, left non-bom (error), right bom (correct)

w-e-w avatar Oct 17 '22 14:10 w-e-w

webui-user.bat is not to be edited

AUTOMATIC1111 avatar Oct 18 '22 05:10 AUTOMATIC1111

understood, I opened a new pull request on a clean branch https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/3056#issue-1413117756

w-e-w avatar Oct 18 '22 12:10 w-e-w