Bug 82462 - load and save don't work with german Umlauts, utf8
Summary: load and save don't work with german Umlauts, utf8
Status: RESOLVED FIXED
Alias: None
Product: kturtle
Classification: Applications
Component: general (show other bugs)
Version: 0.6
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Anne-Marie Mahfouf
URL:
Keywords:
: 105238 156793 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-05-29 19:56 UTC by Matthias Meßmer
Modified: 2008-01-27 17:38 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch that fixes the problem for me (1.82 KB, patch)
2005-08-31 13:37 UTC, Albert Astals Cid
Details
the patch breaks KTurtle for me in French (33.99 KB, image/png)
2005-10-03 03:38 UTC, Anne-Marie Mahfouf
Details
KTurtle in French without the patch (35.56 KB, image/png)
2005-10-03 03:45 UTC, Anne-Marie Mahfouf
Details
Patch for fix this bug (519 bytes, text/x-diff)
2007-05-03 10:55 UTC, Andrey Cherepanov
Details
Modified patch (494 bytes, text/x-diff)
2007-05-03 11:42 UTC, Andrey Cherepanov
Details
Patch for fix saving (1.19 KB, patch)
2007-05-03 12:26 UTC, Andrey Cherepanov
Details
Patch for fix saving (1.18 KB, patch)
2007-05-03 13:23 UTC, Andrey Cherepanov
Details
KTurtle before saving, program is ok (8.18 KB, image/png)
2007-06-16 14:05 UTC, Bozidar Proevski
Details
KTurtle after saving, program is garbled (11.83 KB, image/png)
2007-06-16 14:06 UTC, Bozidar Proevski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Meßmer 2004-05-29 19:56:16 UTC
Version:           0.1 (using KDE 3.2.2,  (testing/unstable))
Compiler:          gcc version 3.3.3 (Debian 20040401)
OS:                Linux (i686) release 2.4.23-1-k7

Saving logo files with special characters like in german keywords are not saved properly. The Program shows an error message: "... the selected encoding cannot encode every unicode character in it..."
Comment 1 Anne-Marie Mahfouf 2004-05-31 00:06:49 UTC
what is your encoding set to in Settings -> Advanced Settings -> Configure Editor?
Comment 2 Matthias Meßmer 2004-05-31 09:57:53 UTC
It was iso8859-1. I changed to UTF-8 in open/save and spelling tab. I didn't find any other encoding options in the editor settings. 

Now I got no error message at saving a file any more, but the special german chars are converted to _very_ special non german chars. So after saving the code has syntax errors and can not be run.

I am using kdelibs from debian SID, so perhaps it is a bug in that texteditor version?
Comment 3 Anne-Marie Mahfouf 2004-05-31 14:01:13 UTC
It works on my box where the editor in KTurtle is set to iso8859-1. The German special characters are all displayed and saved correctly as utf8 bu KTurtle. If I set the editor part encodong to utf8, it does work.
I'll try to ask for more testers for German to try to see what the problem is and I'll ask around to see how generally this encoding problem is tackled.
Comment 4 Anne-Marie Mahfouf 2004-06-22 17:28:59 UTC
ok, Stephan Asserhall discovered a parsing problem and fixed it so could you please update to today's sources and see if the problem is fixed?
Thanks in advance!
Comment 5 Matthias Meßmer 2004-06-22 20:54:55 UTC
Seems to be ok now, if i set open/save and spell checking encoding to UTF-8, too.
Comment 6 Anne-Marie Mahfouf 2004-06-23 03:19:56 UTC
*** Bug has been marked as fixed ***.
Comment 7 Jure Repinc 2005-02-04 04:07:47 UTC
I think I have a similar or the same problem with special Slovenian (or latin 2) characters.

When I try to save a file with one of the letters šđžćč in it I get the same error dialog about wrong encoding and after canceling it I get another dialog saying how file couldn't be read (even though I'm saving file). The instructions in editor window also change to some strange two letter characters for every special latin 2 character.

If I check settings for editor it is set to KDE-Default (which I guess is the same as the one set for current KDE locale, which in my case is ISO-8859-2) which I think should be able to save any of the šđžćč letter.

I'm using KDE 3.4 and kturtle compiled from recent CVS sources.
Comment 8 Cies Breijs 2005-05-25 22:09:32 UTC
i reopened it because it is reported several times again...
Comment 9 Cies Breijs 2005-05-25 22:13:30 UTC
*** Bug 105238 has been marked as a duplicate of this bug. ***
Comment 10 Albert Astals Cid 2005-08-31 13:37:23 UTC
Created attachment 12434 [details]
Patch that fixes the problem for me

Hello, using the katepart to use the loading and saving fixes the problem for
me, it also can seem that i removed the warning about loading a file when
there's an unsaved one, but katepart also takes care of that. Can you please
test if this patch works for you also?
Comment 11 Anne-Marie Mahfouf 2005-10-03 03:38:42 UTC
Created attachment 12819 [details]
the patch breaks KTurtle for me in French

The above patch totally breaks KTurtle for me as the French accents are not
shown anymore.
Comment 12 Anne-Marie Mahfouf 2005-10-03 03:45:43 UTC
Created attachment 12820 [details]
KTurtle in French without the patch

Without the patch, KTurtle displays correctly the accented french characters on
my machine.
My system is not utf8 globally
LANG=en_US
LANGUAGE=en_US:en
Comment 13 Peter Wirdemo 2007-02-19 00:59:22 UTC
Hello!
I'm using kturtle 0.6 on kubuntum /Linux (i686) release 2.6.17-11-386.
There is still a problem with saving and loading files with international characters. I have tried UTF8/16 ISO8858-15 and other without luck.
/Peter
Comment 14 Andrey Cherepanov 2007-05-03 10:55:58 UTC
Created attachment 20463 [details]
Patch for fix this bug

Remove double convert to UTF-8 (widget already returns text in UTF-8).
Comment 15 Andrey Cherepanov 2007-05-03 11:42:14 UTC
Created attachment 20465 [details]
Modified patch

Simle remove two lines of conversions.
Comment 16 Andrey Cherepanov 2007-05-03 12:26:12 UTC
Created attachment 20466 [details]
Patch for fix saving

Patch fix problem on saving in both UTF-8 and 8bit locales.
Comment 17 Andrey Cherepanov 2007-05-03 13:23:48 UTC
Created attachment 20467 [details]
Patch for fix saving 
 




Fix last patch.
Comment 18 Bozidar Proevski 2007-06-16 12:06:53 UTC
Hi

I can confirm that the bug is still present in KDE 3.5.7

Best regards
Bozidar Proevski

Comment 19 Anne-Marie Mahfouf 2007-06-16 13:10:31 UTC
Bozidar: please precise your distribution and what LANG it uses.
Then please precise what language you are having problem with.
Thanks in advance,

Anne-Marie
Comment 20 Bozidar Proevski 2007-06-16 14:04:29 UTC
I'm using slackware 11.0 with KDE downloaded and compiled with konstruct.
LANG=mk_MK.UTF-8 and I'm having problems with macedonian language.

I can open a file and execute it, change it and execute again with no problem. After i save the file, the contents becomes garbled and no longer functions.
I'm attaching two screenshots, one before and one just after saving the file.

I commented this line (383 in my sources), 
  editorInterface->setText( mString.utf8() );
and I had no problems after that.
But I think that Andrey's patch is better.

Best regards
Bozidar Proevski
Comment 21 Bozidar Proevski 2007-06-16 14:05:31 UTC
Created attachment 20870 [details]
KTurtle before saving, program is ok
Comment 22 Bozidar Proevski 2007-06-16 14:06:26 UTC
Created attachment 20871 [details]
KTurtle after saving, program is garbled
Comment 23 Anne-Marie Mahfouf 2007-06-16 17:25:50 UTC
yes Andrey's patch also works for me. 
Comment 24 Anne-Marie Mahfouf 2007-06-16 17:31:27 UTC
SVN commit 676298 by annma:

Fix critical bug when the user language is UTF8
Special thanks to Andrey and Bozidar for the time they spent on that.
BUG=82462


 M  +0 -2      kturtle.cpp  


--- branches/KDE/3.5/kdeedu/kturtle/src/kturtle.cpp #676297:676298
@@ -379,8 +379,6 @@
 	if ( url.isEmpty() ) slotSaveAs();
 	else
 	{
-		QString mString = editorInterface->text(); // get the text
-		editorInterface->setText( mString.utf8() ); // convert it to utf8
 		editor->document()->saveAs(url); // use the KateParts method for saving
 		loadFile(url); // reload the file as utf8 otherwise display weird chars
 		setCaption( url.fileName() );
Comment 25 Andrey Cherepanov 2007-06-16 23:04:33 UTC
Why do you miss important part of my patch?
---------
@@ -45,6 +45,7 @@
 #include <ktexteditor/cursorinterface.h>
 #include <ktexteditor/editorchooser.h>
 #include <ktexteditor/editinterface.h>
+#include <ktexteditor/encodinginterface.h>
 #include <ktexteditor/highlightinginterface.h>
 #include <ktexteditor/printinterface.h>
 #include <ktexteditor/selectioninterface.h>
@@ -195,6 +196,7 @@
 	editor = doc->createView (editorDock, 0L);
 	// editorInterface is the editor interface which allows us to access the text in the part
 	editorInterface = dynamic_cast<KTextEditor::EditInterface*>(doc);
+	dynamic_cast<KTextEditor::EncodingInterface*>(doc)->setEncoding("UTF-8");
---------
If you miss this changes, KTurtle still have this bug on 8bit locales. Please, apply my patch completely.
Comment 26 Anne-Marie Mahfouf 2007-06-17 10:13:21 UTC
SVN commit 676589 by annma:

sorry Andrey, applied patch totally
(my system is not UTF-8 so it works OK without the patch)
BUG=82462


 M  +2 -0      kturtle.cpp  


--- branches/KDE/3.5/kdeedu/kturtle/src/kturtle.cpp #676588:676589
@@ -50,6 +50,7 @@
 #include <ktexteditor/selectioninterface.h>
 #include <ktexteditor/undointerface.h>
 #include <ktexteditor/viewcursorinterface.h>
+#include <ktexteditor/encodinginterface.h>
 
 #include "lexer.h"
 #include "settings.h"
@@ -195,6 +196,7 @@
 	editor = doc->createView (editorDock, 0L);
 	// editorInterface is the editor interface which allows us to access the text in the part
 	editorInterface = dynamic_cast<KTextEditor::EditInterface*>(doc);
+	dynamic_cast<KTextEditor::EncodingInterface*>(doc)->setEncoding("UTF-8");
 	editorDock->setWidget(editor);
 
 	// default the highlightstyle to "logo" using the needed i18n
Comment 27 Pino Toscano 2008-01-27 17:38:11 UTC
*** Bug 156793 has been marked as a duplicate of this bug. ***