PistonDevelopers / VisualRust

Visual Studio extension for Rust
MIT License
703 stars 72 forks source link

Change encoding of .rs files in templates to UTF-8 #257

Closed Vbif closed 8 years ago

Vbif commented 8 years ago

Fix https://github.com/PistonDevelopers/VisualRust/issues/256

Boddlnagg commented 8 years ago

Does this add a BOM (it's hard to see in the diff)? Is that the only way to make VisualStudio use UTF-8 for these files? Also, Cargo.toml should be handled the same, because it may also contain UTF-8 (see https://github.com/rust-lang/cargo/issues/2031).

Vbif commented 8 years ago

Yes this commit add the BOM. Cargo files already with BOM.

Boddlnagg commented 8 years ago

Thanks!

briansmith commented 8 years ago

Sorry to chime in late, but I'm pretty sure nobody wants BOMs. A while back I did an informal survey amongst open-source developers I know and the response was 100% hate.

I'd rather have the VisualRust extension automatically switch the encoding to UTF-8 for all .rs files. As stated in https://doc.rust-lang.org/reference.html#input-format, UTF-8 is the only allowed encoding.

Vbif commented 8 years ago

@briansmith this need further investigation @Boddlnagg I think https://github.com/PistonDevelopers/VisualRust/issues/256 need to be reopened

andersforsgren commented 8 years ago

When I did the BOM handling in toml-rs (for Cargo.toml) it was out of pure necessity, simply because Visual Studio by default adds the BOMs whenever saving an UTF-8 file. I think everyone hates BOMs but if VS will always write BOMs anyway them it's better to consistently have BOMs, than to have them show up at the next save. Starting from a UTF-8 text file without BOM you get an (invisible) diff after saving. So since the rust template files are intended purely for VS, and VS is going to add a BOM later - shouldn't they ideally be UTF-8 files with BOM to begin with?

If VS can be persuaded to write an UTF-8 file without BOM then the story is different of course.

Vbif commented 8 years ago

This looks posible, because there is already such solution https://vlasovstudio.com/fix-file-encoding/

Boddlnagg commented 8 years ago

I would be happy with any change that makes this possible without a BOM, but currently I'm following the reasoning of @andersforsgren. I opened #259 to track this.