2

This is a follow up problem to a question I posed earlier. Basically when I do this:

sed '/Q/{
s/Q//g
r /Users/ericbrotto/Desktop/question.txt
}' Commision.txt

everything is fine, but the new output just prints to a console.

When I do this:

sed '/Q/{
s/Q//g
r /Users/ericbrotto/Desktop/question.txt
}' Commision.txt > newFile

the output prints to file, but my new string (the one that was properly replaced in the previous output) now reads as a bunch of asian (I believe Mandarin) characters.

Any ideas?

Community
  • 1
  • 1
Eric Brotto
  • 53,471
  • 32
  • 129
  • 174
  • 2
    please post the output of the cmd `locale`, as executed in a local shell, AND if your sed script is wrapped in a shell script, then put it before and after the call to sed, or at least look at those outputs to see if you can identify any differences. Good luck. – shellter Jul 23 '11 at 07:20
  • Also I think it's necessary to know more about what you have in the file question.txt -- is it just ASCII, or something else? – tripleee Aug 06 '11 at 06:50

1 Answers1

1

It sounds like you have an encoding mismatch.

I wager that your shell, Commision.txt and question.txt don't all have the same encoding. Because of that, sed is replacing part of a wide character that it doesn't recognize as wide. All subsequent character encodings are off by half a character, and the result is Chinese.

See this question for discussion of a similar problem.

Community
  • 1
  • 1
blahdiblah
  • 33,069
  • 21
  • 98
  • 152