Removing special chars from variable
Go to solution
Solved by tikker,
34 minutes ago, RageAx said:Can you use iconv on variables? I thought you can only use it on files.
And even if I use it on a file it justs returns '?' and not the respective character
You can make just pipe it in:
username_in="čćšžđ"; username_out=$(echo $username_in | iconv -f UTF-8 -t ASCII//TRANSLIT); echo 'Input:' $username_in echo 'Output: ' $username_out
which gives
Input: čćšžđ Output: ccszd
Replace UTF-8 with whatever encoding your usernames have. The //TRANSLIT part tries to approximate characters that aren't in the target encoding with similar looking characaters.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now