Skip to content

Commit c1c6aa6

Browse files
committed
Fixed opening/creating shapefile with åäö in path/filename.
1 parent 48f6308 commit c1c6aa6

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/Shapefile/dbf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
DBFHandle SHPAPI_CALL DBFOpen_MW( CStringW pszFilename, const char * pszAccess )
1414
{
15-
CStringA nameA = Utility::ConvertToUtf8(pszFilename);
15+
CStringA nameA = Utility::ConvertToAnsi1252(pszFilename);
1616
m_globalSettings.SetGdalUtf8(true);
1717
DBFHandle handle = DBFOpen(nameA, pszAccess);
1818
m_globalSettings.SetGdalUtf8(false);
@@ -21,7 +21,7 @@ DBFHandle SHPAPI_CALL DBFOpen_MW( CStringW pszFilename, const char * pszAccess )
2121

2222
DBFHandle SHPAPI_CALL DBFCreate_MW( CStringW nameW )
2323
{
24-
CStringA nameA = Utility::ConvertToUtf8(nameW);
24+
CStringA nameA = Utility::ConvertToAnsi1252(nameW);
2525
m_globalSettings.SetGdalUtf8(true);
2626
DBFHandle handle = DBFCreate(nameA);
2727
m_globalSettings.SetGdalUtf8(false);

src/Utilities/UtilityFunctions.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "StdAfx.h"
1+
#include "StdAfx.h"
22
#include <iterator>
33
#include <fstream>
44
#include "macros.h"
@@ -39,6 +39,15 @@ namespace Utility
3939
return utf8;
4040
}
4141

42+
// ********************************************************
43+
// ConvertToAnsi1252()
44+
// ********************************************************
45+
CStringA ConvertToAnsi1252(CStringW unicode) {
46+
USES_CONVERSION;
47+
CStringA acp = CW2A(unicode, CP_ACP);
48+
return acp;
49+
}
50+
4251
// ********************************************************
4352
// ConvertFromUtf8()
4453
// ********************************************************
@@ -705,6 +714,9 @@ namespace Utility
705714
}
706715
break;
707716
}
717+
case admMetricMeters:
718+
localizedUnits = lsSquareMeters;
719+
break;
708720
case admHectars:
709721
{
710722
area /= 10000.0;

src/Utilities/UtilityFunctions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ namespace Utility
1818

1919
CString UrlEncode(CString s);
2020
CStringW XmlFilenameToUnicode(CStringA s, bool utf8);
21-
CStringA ConvertToUtf8(CStringW unicode);
21+
CStringA ConvertToUtf8(CStringW unicode);
22+
CStringA ConvertToAnsi1252(CStringW unicode);
2223
CStringW ConvertFromUtf8(CStringA utf8);
2324
CString GetSocketErrorMessage(DWORD socketError);
2425

0 commit comments

Comments
 (0)