-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non UTF-8 encoding support #117
Comments
The test in question is it "returns the basename with the same encoding as the original" do
basename = File.basename('C:/Users/Scuby Pagrubý'.encode(Encoding::Windows_1250))
basename.should == 'Scuby Pagrubý'.encode(Encoding::Windows_1250)
basename.encoding.should == Encoding::Windows_1250
end To make Rust happy the following works but some bytes of character data is lost in translation def self.basename(pth, ext="")
Rust.basename(
pth.encode(Encoding::UTF_8),
ext.encode(Encoding::UTF_8)
).force_encoding(pth.encoding)
end The test output result is
|
Not that this is relevant, but just an FYI: Windows-1250 is a single byte encoding. It only encodes 256 possible characters. The first 128 characters match ASCII-7BIT, and the second half is mostly accented latin letters. |
Thanks @glebm . Since I've rewritten this project in ruru the point of this issue is now to update the capabilities of RString in ruru. New error on TravisCI:
Unless they have alternate encoding support through alternate means. I still need to look into this. |
I've been thinking looking at FFI and Fiddle may give insight for where to integrate encoding from Ruby's C code. |
Good NewsWith the addition of encoding support in Rutie and the |
The Ruby spec has a test with windows encoded string basename_spec.rb#L162-L166 . This encoding is not UTF-8 compatible and is likely a variation on UTF-16 or UCS-2. Rust wasn't built to support these with the standard
String
or&str
so custom types would need to be written to support such encodings.The occurrence of these encodings should be virtually non-existent in web frameworks so problems would likely only arise in Windows specific applications.
Work that has been done in the community towards making a working solution includes
This would make much more sense to implement in FasterPath once windows support has been added and code compiles specifically for Windows. So this should be considered after #102
The text was updated successfully, but these errors were encountered: