hi all,
I have a ini file in UTF-8, I am using GetPrivateProfi leStringA() for reading and WriteprivatePro fileStringA() for writing into the ini file. I am writing multibyte data into the file (using normal char *). so ini file is saved in UTF-8. And ini file is maintained in App data folder in windows systems.
Now the problem is.
if a user has unicode username, then SHgetFolderPath () -- with CSIDL_APPDATA option would return a path with that unicode username as part of it. I am handling all these in utf8. now GetPrivateProfi leStringA() is failing with this path since it can only handle ANSI paths.
I am Not using GetprivateProfi leStringW() and WritePrivatePro fileStringW() since it wont save ini files in unicode! it is saving ini files inj ANSI eventhough I supply unicode data.
Waiting for your Reply,
Xoinki
4 16991
You do not ever call GetPrivateProfi leStringA() or GetProfileStrin gW().
Instead, you include tchar.h and call GetPrivatePrile String(). Read this.
Notice the arguments s LPCTSTR, which are long pointers to constant TCHAR strings.
Whether ASCII or Unicode is used, is determined by the character set you specify in your project settings. GetPrivateProfi leString() will resolve to GetPrivateProfi leStringA() or GetProfileStrin gW() based on that setting. And the argiments will resolve to LPCSTR or LPCWSTR.
Be sure to use a _tmain() and observe all _t and _T functions plus use the TEXT macro. If you don't things won't work.
hi,
Thnx for the reply.
I am compiling My application with UNICODE and _UNICODE defined.
so if i use Getprivateprofi lestring() then it would internally use GetPrivateProfi leStringW().. My problem is if i use this function to write unicode data into ini.. It should save ini file in Unicode format.. but it doesnt..
http://blogs.msdn.com/michkap/archive/2006/09/15/754992.aspx
So what I am doining is I am using WritePrivatePro fileStringA() and writing UTF-8 data so forcing the file to be in UTF-8. but this works in all cases except when the path parameter has some utf-8 characters. It fails this case because WritePrivatePro fileStringA() doesnt understand Utf-8 path.
So I am in dilemma of what to do so that ini file is in Utf8.
Is there any way to maintain ini file in utf8 without using WritePrivatePro fileStringA() ?
Regards,
Xoinki
hi,
I found out that opening a ini file and writing Unicode BOM explicitly would write unicode data properly when WriteProfileStr ingW() is used.. but this doesnt help since I want ini to be in Utf-8 any idea how i can maintain ini file in Utf8 and use utf8 paths??
Regards
Xoinki
hi,
I got the problem solved by using a customatized ini-handler. Not using any MS API's, It just creates a separate Linked list for storing section info, key info, value info.. and a simple parser for fetching desired values.. It is funny that we are replacing MS API's coz of one limitation or other.. Earlier it was Codepage detection API's which are flawed(although quick).
Thnx
Xoinki
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mark Hayworth |
last post by:
Randy:
I too am having the problem that this other guy/girl had. I put in
the proper API declarations and arguments for GetPrivateProfileString
yet it doesn't return the correct stuff. It always returns the
default value (padded with huge amount of spaces on the right) and the
return value (number of characters read) is some crazy huge number
like 51298398749084
Your demo doesn't work in .Net - it's for prior versions of VB, and so
the...
|
by: pekka niiranen |
last post by:
Hi there,
I have two files "my.utf8" and "my.utf16" which
both contain BOM and two "a" characters.
Contents of "my.utf8" in HEX:
EFBBBF6161
Contents of "my.utf16" in HEX:
FEFF6161
|
by: L |
last post by:
static extern uint GetPrivateProfileString(
string lpAppName,
string lpKeyName,
string lpDefault,
StringBuilder lpReturnedString,
uint nSize,
string lpFileName);
Interoping GetPrivateProfileString is giving me this Exception in
|
by: Domac |
last post by:
I need to read some configuration data from .ini file located at
Application.StartupPath location .
Here is code snippet :
Public Declare Unicode Function GetPrivateProfileString Lib "kernel32" Alias
"GetPrivateProfileStringW" (ByVal lpApplicationName As String, ByVal
lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As
String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32
|
by: 海风 |
last post by:
A question about GetPrivateProfileString
a section in a .ini file , for example
ip = 192.168.1.112
....
i want to get the ip value by using GetPrivateProfileString() function.
the code is :
| |
by: Thanh-Nhan Le |
last post by:
Hi,
Is there any way to use the API function WritePrivateProfileString in NET
framework 2.0?
Thanks
Nhan
|
by: Nhan |
last post by:
Hi,
I am trying to use the function GetPrivateProfileString as following:
public static extern Int32 GetPrivateProfileString(string lpAppName, string
lpKeyName, string lpDefault, string lpReturnedString, short nSize, string
lpFileName);
.......
String sDatabase = "";
|
by: Bexm |
last post by:
Hello
Yes I know before you say I know INI files are outdated and xml should be used instead, but I have a very specific reason and an INI file must be used as it is also being used by an old VB app.
I have a C# asp.net application which has been running quite happily using WritePrivateProfileString() from KERNEL32 and writing to my INI file, but for some reason this has stopped working, so I now need another method.
Does anyone have...
|
by: alag20 |
last post by:
Hi Guys,
I need some urgent help with this as I am becoming clueless now.
I have 2 DllImport as below from Kernel32
private static extern int GetPrivateProfileString(string section, int key, string defaultValue, byte result, int size, string fileName);
private static extern int GetPrivateProfileString(string section, string key, string defaultValue, StringBuilder result, int size, string fileName);
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |