Quick fix for character sets causing you a problem is simply to convert to two-character hex representation of the ASCII value - this way you only have 0-9,A-F in your strings.

The down-side is that it doubles the size of your data, but where it is short enough that's rarely important. In your case you probably aren't going to exceed the file block size, so you won't be using any additional disk.