KCM: Make sure Unicode is used for editing bashrc (fixes issue #6)
#7
Merged
blu.256
merged 1 commits from fix/issue-6
into master
3 years ago
@ -509,13 +509,14 @@ void KcmGtk::save()
|
||||
if (file.exists())
|
||||
{
|
||||
file.open(IO_ReadOnly);
|
||||
TQByteArray fileData = file.readAll();
|
||||
TQTextStream fileDataStream = TQTextStream(&file);
|
||||
|
||||
fileDataStream.setEncoding(TQTextStream::Locale);
|
||||
TQString fileDataString = fileDataStream.read();
|
||||
file.close();
|
||||
|
||||
TQString rcLine = "export GTK2_RC_FILES=$HOME/.gtkrc-2.0";
|
||||
TQString fileDataString(fileData);
|
||||
fileDataString.replace("\n" + rcLine, "\n# (This is no longer needed from version 0.8 of the theme engine)\n# " + rcLine);
|
||||
|
||||
|
||||
file.open(IO_WriteOnly);
|
||||
stream.setDevice(TQT_TQIODEVICE(&file));
|
||||
SlavekB marked this conversation as resolved
SlavekB
commented 3 years ago
Review
One more idea: Encoding should also be set when writing data back to file? One more idea: Encoding should also be set when writing data back to file?
blu.256
commented 3 years ago
Review
I don't know; right now it works well. Maybe encoding should only be set when reading from stream? According to the TQt docs,
so if I understood that well, it sets the appropriate encoding automatically for the output. I don't know; right now it works well. Maybe encoding should only be set when reading from stream?
According to the TQt docs,
> By default, output of Unicode text (i.e. TQString) is done using the local 8-bit encoding.
so if I understood that well, it sets the appropriate encoding automatically for the output.
SlavekB
commented 3 years ago
Review
Ok, thank you, in this case it should probably be fine. Ok, thank you, in this case it should probably be fine.
|
||||
stream << fileDataString;
|
||||
|
Loading…
Reference in New Issue
Now I found that there is already
TQTextStream stream(&file);
forfile
defined above. So you can use the previousstream
variable. Instead of a newfileDataStream
.I'll do a test if it also solves the FTBFS, which I watch now.
I just checked with the following changes:
Builds and works as expected.
For me build was successful only on Debian 12 (Bookworm), Ubuntu 21.10 (Impish) and Ubuntu 22.04 (Jammy). With an update in #8 build is successfull also on Debian 9 (Stretch).