minad / olelo

Wiki with git backend
MIT License
241 stars 44 forks source link

Using non ascii characters makes pages non-editable #18

Closed codingisacopingstrategy closed 14 years ago

codingisacopingstrategy commented 14 years ago

Using the wiki creole backend.

Editing pages works fine, until I insert a non ascii character (like a typographic quote ‘, or an é). Saving works, but trying to then edit gives an error:

Test2 is a Creole Wiki Text (text/x-creole) and cannot be edited like a text file.
minad commented 14 years ago

I modified the behaviour in 235ce0aa5773d5d798614955015a32e83e77fa90. The editor shows a warning if the file seems to be binary. If the encoding is binary (Ascii-8bit) in ruby 1.9 an error is shown and the file cannot be edited.

codingisacopingstrategy commented 14 years ago

Thanks, it works for me now. Although the described behaviour in Ruby 1.9 seems undesirable? Isn’t almost all text Ascii-8bit, especially for Europeans?

minad commented 14 years ago

No in ruby 1.9 utf-8 is allowed. If the encoding is not utf-8 but ascii-8bit, it is a binary file (for example an image). Then it cannot be edited this way. The check is done by forcing the encoding to utf-8 (force_encoding) and checking the encoding afterwards via valid_encoding?. If the encoding is invalid, it is assumed, that the file is binary.

minad commented 14 years ago

fixed