← Back to team overview

kicad-developers team mailing list archive

UTF8 source files

 

We introduced a patch today which introduces UTF8 encoding into a couple of source files,
then made a policy decision to allow UTF8 string constants in 8 bit strings.  So this is
currently about 3 places only, nothing to worry about yet.

The only time you can be sure you have an 8 bit string is if it is not wrapped in wxT().

pcb_calculator uses some 8 bit strings.  In the future we will see more as wx 2.8 fades away.

You should setup your programming editors to use UTF-8 encoding in the near future.

After doing that, to check your editor, try loading the attached patch.  The "um" text in
the patch should show the greek mu in the micron const string near UNIT_MICRON


   http://en.wikipedia.org/wiki/Mu_%28letter%29


We will be adding this to the coding standards document also.

Note that ASCII files pass as UTF-8 files, but not vice versa.  So for a long time, and on
most *.cpp files there will never be any difference.  Patches will still come in as ASCII,
especially from new people.   Only when we have:

a) in internationally recognized character, that is
b) not ASCII, in a
c) 8 bit string.

will this ever be an issue moving forward.  And until wx 2.8 goes away, it is very limited
in where we can *know* we have 8 bit strings, due to the wxT() wrapper in play in wx 2.8.
 wxT() abstracts the bitness of the strings on different platforms and builds.

Again, the test file is attached.

Regards,

Dick

=== modified file 'cvpcb/menubar.cpp'
--- cvpcb/menubar.cpp	2012-04-09 09:16:47 +0000
+++ cvpcb/menubar.cpp	2013-05-02 14:19:32 +0000
@@ -95,7 +95,7 @@
     // Save as the .cmp file
     AddMenuItem( filesMenu,
                  wxID_SAVEAS,
-                 _( "Save &As..." ), SAVE_AS_HLP_MSG, KiBitmap( save_xpm ) );
+                 _( "Save &As...\tCtrl+Shift+S" ), SAVE_AS_HLP_MSG, KiBitmap( save_xpm ) );
 
     // Separator
     filesMenu->AppendSeparator();

=== modified file 'cvpcb/readwrite_dlgs.cpp'
--- cvpcb/readwrite_dlgs.cpp	2013-04-28 20:20:40 +0000
+++ cvpcb/readwrite_dlgs.cpp	2013-05-02 14:19:32 +0000
@@ -166,8 +166,8 @@
     }
     else
     {
-        wxFileDialog dlg( this, _( "Save Component Footprint Link File" ), wxGetCwd(),
-                          wxEmptyString, ComponentFileWildcard, wxFD_SAVE );
+        wxFileDialog dlg( this, _( "Save Component Footprint Link File" ), wxEmptyString,
+                          _( "Unnamed file" ), ComponentFileWildcard, wxFD_SAVE );
 
         if( dlg.ShowModal() == wxID_CANCEL )
             return -1;

=== modified file 'kicad/kicad.cpp'
--- kicad/kicad.cpp	2013-01-13 16:55:07 +0000
+++ kicad/kicad.cpp	2013-05-02 14:19:32 +0000
@@ -56,21 +56,17 @@
 
     frame->m_ProjectFileName = fn;
 
-    if( m_fileHistory.GetCount() )
+    if( !frame->m_ProjectFileName.FileExists() )
     {
-        frame->m_ProjectFileName = m_fileHistory.GetHistoryFile( 0 );
-
-        if( !frame->m_ProjectFileName.FileExists() )
-        {
-            m_fileHistory.RemoveFileFromHistory( 0 );
-        }
-        else
-        {
-            wxCommandEvent cmd( 0, wxID_FILE1 );
-            frame->OnFileHistory( cmd );
-        }
+        m_fileHistory.RemoveFileFromHistory( 0 );
+        return;
     }
 
+    wxCommandEvent loadEvent;
+    loadEvent.SetId( wxID_ANY );
+  
+    frame->OnLoadProject( loadEvent );
+
     wxString title = GetTitle() + wxT( " " ) + GetBuildVersion() +
                      wxT( " " ) + frame->m_ProjectFileName.GetFullPath();
 

=== modified file 'pcb_calculator/transline/c_microstrip.cpp'
--- pcb_calculator/transline/c_microstrip.cpp	2012-09-21 17:02:54 +0000
+++ pcb_calculator/transline/c_microstrip.cpp	2013-05-02 14:19:32 +0000
@@ -869,7 +869,7 @@
     setResult( 4, atten_dielectric_e, "dB" );
     setResult( 5, atten_dielectric_o, "dB" );
 
-    setResult( 6, skindepth / UNIT_MICRON, "µm" );
+    setResult( 6, skindepth / UNIT_MICRON, "µm" );
 }
 
 

=== modified file 'pcb_calculator/transline/coplanar.cpp'
--- pcb_calculator/transline/coplanar.cpp	2012-09-21 17:02:54 +0000
+++ pcb_calculator/transline/coplanar.cpp	2013-05-02 14:19:32 +0000
@@ -184,7 +184,7 @@
     setResult( 1, atten_cond, "dB" );
     setResult( 2, atten_dielectric, "dB" );
 
-    setResult( 3, skindepth / UNIT_MICRON, "µm" );
+    setResult( 3, skindepth / UNIT_MICRON, "µm" );
 }
 
 

=== modified file 'pcb_calculator/transline/microstrip.cpp'
--- pcb_calculator/transline/microstrip.cpp	2012-09-21 17:02:54 +0000
+++ pcb_calculator/transline/microstrip.cpp	2013-05-02 14:19:32 +0000
@@ -511,7 +511,7 @@
     setResult( 1, atten_cond, "dB" );
     setResult( 2, atten_dielectric, "dB" );
 
-    setResult( 3, skindepth/UNIT_MICRON, "µm" );
+    setResult( 3, skindepth/UNIT_MICRON, "µm" );
 }
 
 

=== modified file 'pcb_calculator/transline/stripline.cpp'
--- pcb_calculator/transline/stripline.cpp	2012-09-21 17:02:54 +0000
+++ pcb_calculator/transline/stripline.cpp	2013-05-02 14:19:32 +0000
@@ -123,7 +123,7 @@
     setResult( 1, atten_cond, "dB" );
     setResult( 2, atten_dielectric, "dB" );
 
-    setResult( 3, skindepth / UNIT_MICRON, "µm" );
+    setResult( 3, skindepth / UNIT_MICRON, "µm" );
 }
 
 

=== modified file 'pcb_calculator/transline/twistedpair.cpp'
--- pcb_calculator/transline/twistedpair.cpp	2012-09-21 17:02:54 +0000
+++ pcb_calculator/transline/twistedpair.cpp	2013-05-02 14:19:32 +0000
@@ -84,7 +84,7 @@
     setResult( 1, atten_cond, "dB" );
     setResult( 2, atten_dielectric, "dB" );
 
-    setResult( 3, skindepth / UNIT_MICRON, "µm" );
+    setResult( 3, skindepth / UNIT_MICRON, "µm" );
 }
 
 

=== modified file 'pcbnew/Info.plist'
--- pcbnew/Info.plist	2011-08-30 07:35:40 +0000
+++ pcbnew/Info.plist	2013-05-02 14:19:32 +0000
@@ -11,6 +11,7 @@
 			<string>pcbnew_doc.icns</string>
 			<key>CFBundleTypeExtensions</key>
 			<array>
+				<string>kicad_pcb</string>
 				<string>brd</string>
 			</array>
 			<key>CFBundleTypeName</key>

=== modified file 'pcbnew/files.cpp'
--- pcbnew/files.cpp	2013-04-05 07:38:00 +0000
+++ pcbnew/files.cpp	2013-05-02 14:19:32 +0000
@@ -445,12 +445,17 @@
 
         pcbFileName = GetBoard()->GetFileName();
 
+        if( pcbFileName.GetName() == wxEmptyString )
+        {
+            pcbFileName.SetName( _( "Unnamed file" ) );
+        }
+
         // Match the default wildcard filter choice, with the inital file extension shown.
         // That'll be the extension unless user changes filter dropdown listbox.
         pcbFileName.SetExt( KiCadPcbFileExtension );
 
-        wxFileDialog dlg(   this, _( "Save Board File As" ), wxEmptyString,
-                            pcbFileName.GetFullPath(),
+        wxFileDialog dlg(   this, _( "Save Board File As" ), pcbFileName.GetPath(),
+                            pcbFileName.GetFullName(),
                             wildcard, wxFD_SAVE
                             /* wxFileDialog is not equipped to handle multiple wildcards and
                                 wxFD_OVERWRITE_PROMPT both together.

=== modified file 'pcbnew/menubar_pcbframe.cpp'
--- pcbnew/menubar_pcbframe.cpp	2013-02-23 19:30:43 +0000
+++ pcbnew/menubar_pcbframe.cpp	2013-05-02 14:19:32 +0000
@@ -106,8 +106,8 @@
 
     // Save As
     AddMenuItem( filesMenu, ID_SAVE_BOARD_AS,
-                 _( "Sa&ve As..." ),
-                 _( "Save the current board as.." ),
+                 _( "Sa&ve As...\tCtrl+Shift+S" ),
+                 _( "Save the current board as..." ),
                  KiBitmap( save_as_xpm ) );
     filesMenu->AppendSeparator();
 


Follow ups