View Issue Details

IDProjectCategoryView StatusLast Update
0028815LazarusLCLpublic2016-02-04 15:37
ReporterzbynaAssigned ToBart Broersma 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformintel386-win32OSwindowsOS Versionwindows 7 64bit
Product VersionProduct Build49844 
Target Version1.6Fixed in Version1.6 
Summary0028815: LCLTranslator does not work if national characters in path
DescriptionLCLTranslator does not silently work (no error messages) when project is presented in path with nationals characters
Steps To ReproduceI enclose project which works if in path without national characters
TagsNo tags attached.
Fixed in Revisionr50569
LazTarget1.6
WidgetsetWin32/Win64
Attached Files
  • Preklady_pokus_3.zip (465,343 bytes)
  • publish.zip (7,628 bytes)
  • lcltranslator.pas.patch (712 bytes)
    Index: lcl/lcltranslator.pas
    ===================================================================
    --- lcl/lcltranslator.pas	(revision 49952)
    +++ lcl/lcltranslator.pas	(working copy)
    @@ -96,12 +96,15 @@
       var
         LangShortID: string;
         AppDir,LCFileName,FullLCFileName: String;
    +    Dummy: String;
       begin
         DefaultLang := LangID;
     
         if LangID <> '' then
         begin
    -      AppDir := ExtractFilePath(ParamStrUTF8(0));
    +      Dummy := ExtractFilePath(ParamStrUTF8(0));
    +      AppDir := '';
    +      Insert(AppDir, Dummy, 1);
           LCFileName := ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), LCExt);
           FullLCFileName := ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), '.' + LangID) + LCExt;
     
    
  • ScreenCopy.pdf (544,595 bytes)
  • winlazutf8.inc.patch (490 bytes)
     components/lazutils/winlazutf8.inc | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/components/lazutils/winlazutf8.inc b/components/lazutils/winlazutf8.inc
    index 8f33267..9f3fccb 100644
    --- a/components/lazutils/winlazutf8.inc
    +++ b/components/lazutils/winlazutf8.inc
    @@ -212,7 +212,7 @@ begin
       else
       begin
         if (Param <= ArgsWCount) then
    -      Result := Utf8Encode(ArgsW[Param])
    +      Result := Utf16ToUtf8(ArgsW[Param])
         else
           Result := '';
       end;
    
    winlazutf8.inc.patch (490 bytes)

Relationships

related to 0026453 closedJuha Manninen Memo.Lines and umlauts 
child of 0028857 closedBart Broersma Implicit Codepage Conversion meta issue 

Activities

zbyna

2015-10-09 23:01

reporter  

Preklady_pokus_3.zip (465,343 bytes)

Bart Broersma

2015-10-10 00:26

developer   ~0086404

I cannot reproduce.
Your example app (please remove the dependancy on google.api) translates happily between "cs" and "en" even if I put the app in a folder like:
C:\Users\Bart\LazarusProjecten\bugs\บลูเบอ

Note that the foldername contains Unicode characters outside my current codepage.

(Lazarus 1.5 r49759 FPC 3.0.0RC1 i386-win32-win32/win64)

zbyna

2015-10-11 23:14

reporter   ~0086475

Last edited: 2015-10-11 23:15

View 2 revisions

svn revision: 49844 fpc 3.1.1 i386-win32
I enclose project file obtained via publish command. When I add '_česky' to foldername (eg 'publish_česky') project starts in english despite of SetDefaultLang('cs') in form1.create and runtime language switching does not work.
I am using win7 64bit. with czech national language environment.

I am not aware of google api dependencies in my sample project but it does not mean there is not one :-) Please write me how to remove it if it is the reason why switching languages does not work. Thanks.

zbyna

2015-10-11 23:14

reporter  

publish.zip (7,628 bytes)

Bart Broersma

2015-10-11 23:48

developer   ~0086477

You can remove the dependancy via project inspector IIRC.

zbyna

2015-10-12 22:36

reporter   ~0086511

Thanks, removed google api dedendancy. Issue still persists.

zbyna

2015-10-13 01:36

reporter   ~0086514

After adding -dEnableUTF8RTL and -FcUTF8 (according to http://wiki.freepascal.org/Better_Unicode_Support_in_Lazarus#RTL_with_default_codepage_UTF-8)
 project works even with national characters in path.

Bart Broersma

2015-10-13 20:56

developer   ~0086534

Since I don't have fpc trunk, and 3.0.0rc1 behaves correctly (regardless of the setting of "Utf8 in RTL", can you step through the code to see where it goes wrong?
The problem might be similar to 0028406.

Michl

2015-10-13 23:57

developer   ~0086540

Last edited: 2015-10-14 00:07

View 4 revisions

> The problem might be similar to 0028406.

Yes, it is. I can confirm this issue and can also make such a ugly hack patch ;)


After thinking a while about this behaviour, it is imho a FPC related problem. There is something wrong on the string conversion. Maybe someone of the FPC core members can have a look on that bug?!

Michl

2015-10-13 23:57

developer  

lcltranslator.pas.patch (712 bytes)
Index: lcl/lcltranslator.pas
===================================================================
--- lcl/lcltranslator.pas	(revision 49952)
+++ lcl/lcltranslator.pas	(working copy)
@@ -96,12 +96,15 @@
   var
     LangShortID: string;
     AppDir,LCFileName,FullLCFileName: String;
+    Dummy: String;
   begin
     DefaultLang := LangID;
 
     if LangID <> '' then
     begin
-      AppDir := ExtractFilePath(ParamStrUTF8(0));
+      Dummy := ExtractFilePath(ParamStrUTF8(0));
+      AppDir := '';
+      Insert(AppDir, Dummy, 1);
       LCFileName := ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), LCExt);
       FullLCFileName := ChangeFileExt(ExtractFileName(ParamStrUTF8(0)), '.' + LangID) + LCExt;
 

zbyna

2015-10-14 00:25

reporter   ~0086542

Last edited: 2015-10-14 00:29

View 2 revisions

I enclose hrdcopy screens.
Edit: sorry did not notice the patch.
Thanks

zbyna

2015-10-14 00:25

reporter  

ScreenCopy.pdf (544,595 bytes)

Michl

2015-10-14 00:54

developer   ~0086544

Last edited: 2015-10-14 00:55

View 2 revisions

This patch isn't good. It is only a workaround. I've made a FPC bug report: 0028850 with a simple test project.

zbyna

2015-10-14 21:16

reporter  

winlazutf8.inc.patch (490 bytes)
 components/lazutils/winlazutf8.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/lazutils/winlazutf8.inc b/components/lazutils/winlazutf8.inc
index 8f33267..9f3fccb 100644
--- a/components/lazutils/winlazutf8.inc
+++ b/components/lazutils/winlazutf8.inc
@@ -212,7 +212,7 @@ begin
   else
   begin
     if (Param <= ArgsWCount) then
-      Result := Utf8Encode(ArgsW[Param])
+      Result := Utf16ToUtf8(ArgsW[Param])
     else
       Result := '';
   end;
winlazutf8.inc.patch (490 bytes)

zbyna

2015-10-14 21:17

reporter   ~0086586

Seems like this works:
file - winlazutf8.inc
old: line 215 Result := Utf8Encode(ArgsW[Param])
new: line 215 Result := Utf16ToUtf8(ArgsW[Param])
(please see patch in file section)

malcome

2015-10-17 02:26

reporter   ~0086642

I agree zbyna's patch.
It's better not to depend on New RTL as much as possible.
Because New RTL is buggy.

Bart Broersma

2015-10-17 18:45

developer   ~0086660

Last edited: 2015-10-17 22:13

View 2 revisions

> new: line 215 Result := Utf16ToUtf8(ArgsW[Param])
This only works because Utf16ToUtf8 does not alter the codepage of the string, whereas Utf8EnCode explicitely stes stringcodepage to cp_utf8.

I'm not sure that this is the best solution.
Maybe we should explixitely set stringcodepages in places like this (concatenation of strings provided by RTL and LCL)?
Someone with more insight in cp_string's should give more insight.

> It's better not to depend on New RTL as much as possible.
That's an odd statement.
How are we not going to depend on "new RTL" once we move to fpc 3.0 series?

We must figure out a solid solutions and document the changes made (inside the sourcecode).

All that being said: there is no real objection to using Utf16ToUtf8 in that place (and maybe others).

malcome

2015-10-18 02:04

reporter   ~0086661

Isn't that job of ParamStr function with FPC3.0+?
Why do you expect it to ParamStrUTF8?

Bart Broersma

2015-10-24 12:32

developer   ~0086834

> Isn't that job of ParamStr function with FPC3.0+
Yes, and it works if "Utf8 in RTL" is enabled.
If not then the concatenation of strings goes wrong (because LCL treats all strings as UTF8 encoded and that assumption is incorrect in that case.
ParamStr will return a string with codepage cp_acp and lcl treats it as utf8.

Bart Broersma

2015-12-02 14:35

developer   ~0087752

Please test and close if OK.
(I cannot test myself, I do not have fpc trunk.)

zbyna

2016-02-04 15:37

reporter   ~0089762

svn: 51308 project enclosed in publish.zip works.
Thanks for fixing.

Issue History

Date Modified Username Field Change
2015-10-09 23:01 zbyna New Issue
2015-10-09 23:01 zbyna File Added: Preklady_pokus_3.zip
2015-10-10 00:26 Bart Broersma LazTarget => -
2015-10-10 00:26 Bart Broersma Note Added: 0086404
2015-10-10 00:26 Bart Broersma Status new => feedback
2015-10-11 23:14 zbyna Note Added: 0086475
2015-10-11 23:14 zbyna Status feedback => new
2015-10-11 23:14 zbyna File Added: publish.zip
2015-10-11 23:15 zbyna Note Edited: 0086475 View Revisions
2015-10-11 23:48 Bart Broersma Note Added: 0086477
2015-10-12 22:36 zbyna Note Added: 0086511
2015-10-13 01:36 zbyna Note Added: 0086514
2015-10-13 20:56 Bart Broersma Note Added: 0086534
2015-10-13 23:57 Michl Note Added: 0086540
2015-10-13 23:57 Michl File Added: lcltranslator.pas.patch
2015-10-14 00:04 Michl Note Edited: 0086540 View Revisions
2015-10-14 00:04 Michl Note Edited: 0086540 View Revisions
2015-10-14 00:07 Michl Note Edited: 0086540 View Revisions
2015-10-14 00:25 zbyna Note Added: 0086542
2015-10-14 00:25 zbyna File Added: ScreenCopy.pdf
2015-10-14 00:29 zbyna Note Edited: 0086542 View Revisions
2015-10-14 00:54 Michl Note Added: 0086544
2015-10-14 00:55 Michl Note Edited: 0086544 View Revisions
2015-10-14 08:39 Juha Manninen Relationship added related to 0026453
2015-10-14 21:16 zbyna File Added: winlazutf8.inc.patch
2015-10-14 21:17 zbyna Note Added: 0086586
2015-10-14 23:41 Bart Broersma Relationship added child of 0028857
2015-10-17 02:26 malcome Note Added: 0086642
2015-10-17 18:45 Bart Broersma Note Added: 0086660
2015-10-17 22:13 Bart Broersma Note Edited: 0086660 View Revisions
2015-10-18 02:04 malcome Note Added: 0086661
2015-10-24 12:32 Bart Broersma Note Added: 0086834
2015-12-02 14:35 Bart Broersma Fixed in Revision => r50569
2015-12-02 14:35 Bart Broersma LazTarget - => 1.6
2015-12-02 14:35 Bart Broersma Note Added: 0087752
2015-12-02 14:35 Bart Broersma Status new => resolved
2015-12-02 14:35 Bart Broersma Fixed in Version => 1.6
2015-12-02 14:35 Bart Broersma Resolution open => fixed
2015-12-02 14:35 Bart Broersma Assigned To => Bart Broersma
2015-12-02 14:35 Bart Broersma Target Version => 1.6
2016-02-04 15:37 zbyna Note Added: 0089762
2016-02-04 15:37 zbyna Status resolved => closed