Skip to content

Convert weird chars into their proper version #1089

Closed
@PrzemyslawKlys

Description

@PrzemyslawKlys

Summary of the new feature

I saw this reddit thread https://www.reddit.com/r/PowerShell/comments/9rlj00/why_does_visualstudio_code_keep_borking_my_scripts/ and it reminded me having those problems as well. Basically when you copy/paste code from different websites it looks good but chars like - or ' or " often have weird version of it and it looks like gibberish after you run it.

On website:

Set-ADUser $user –replace @{EmployeeType=$newemployeetype} -WhatIf

When pasted it looks almost the same...

But when run I often see complains and output displays this:

Set-ADUser $user â€replace @{EmployeeType=â€�$newemployeetypeâ€�} -WhatIf

It's also visible when you do something in Word (I know I know), Outlook or other software like that.

In word:

image

After paste

image

After run:

image

This is related to how polish languages treats double quotes. But I am sure it's similar on a lot of websites, wrong templates, old outdated Microsoft resource websites?

Also right now VSCode doesn't regognize this as a problem until it's too late. Normally on errors it would show "red" file but here.. everything is great.

image

As opposed to:

image

Proposed technical implementation details (optional)

I had this conversation with @tylerl0706 on twitter: https://twitter.com/TylerLeonhardt/status/1055859999086235648 and one of proposed implementations was to utilize format on paste, format on save, format on... where it would magically replace those weird chars into their equivalent versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions