|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi,
I need to read unicode strings from a unicode encoded INI in to a Visual Basic 6 Text Control (A forms 2 control). Normally I would use the GetPrivateProfileString function to read from an INI but once the file is encoded in unicode the function return "?????" instead of the real string. Opening the INI with notepad I can see the real string but the GetPrivateProfileStringW function wont read it. Any suggestions on how to read it correctly ? Thanks EB |
|
#2
|
|||
|
|||
|
Private Declare Function GetPrivateProfileString& Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal SectionName$, ByVal KeyName$, ByVal Default$, ByVal ReturnedString$, ByVal Size&, ByVal Filename$)
|
|
#3
|
|||
|
|||
|
Oops I meant to comment that post!
Try the Function ending with "A" |
|
#4
|
|||
|
|||
|
Using the GetPrivateProfileStringA function creates a fatal error:
"The instruction at "0x77e931b6" referenced memory as "0x000000ff". The memory could not be "read". It happens on tree different machine so I don't think it's a problem with the DLL. The code I run is: Private Sub Form_Load() Dim ReturnValueSize As Long Dim ReturnValue As String Dim IniFileName As String IniFileName = ("C:\Documents and Settings\dp18382\Desktop\Tirgolimos\Language Tester.ini") ReturnValue = Space$(255) ReturnValueSize = GetPrivateProfileStringA("Languages", "L1", " ", ReturnValue, Len(ReturnValue), IniFileName) ReturnValue = Left(ReturnValue, ReturnValueSize) End Sub Any suggestions ? EB |
|
#5
|
|||
|
|||
|
Uops ... My mistake .. the function call is OK
BUT it still wont return Spanish special letters. The INI file is encoded using Unicode (In notepad, save as, encoding = Unicode). I can see the characters in notepad but reading it using GetPrivateProfileStringA ends up as a string where the special characters are ??. GetPrivateProfileStringW return with an empty string. Any ideas ? EB |
|
#6
|
|||
|
|||
|
|
|
#7
|
|||
|
|||
|
Am I using it wrong ?
ReturnValue = Space$(255) MBReturnValue = Space$(255) ReturnValueSize = GetPrivateProfileStringA("Languages", "L1", " ", ReturnValue, Len(ReturnValue), IniFileName) ReturnValue = Left(ReturnValue, ReturnValueSize) ReturnValueSize = WideCharToMultiByte(0, 0, ReturnValue, ReturnValueSize, MBReturnValue, Len(MBReturnValue), "-", Flag) MBReturnValue = Left(MBReturnValue, ReturnValueSize) Label1.Caption = StrConv(MBReturnValue, vbUnicode, 2058) When the file is encoded as UTF-8 or Unicode the end value it Label1.Caption is "-" instead of "Espaņol". EB |
|
#8
|
|||
|
|||
|
What did you get before? Something like "Espa?nol" ? Do you need to also use the correct font? <guessing here>
|
|
#9
|
|||
|
|||
|
Yep using the original lines I had received "Espa?nol".
As long as the letter is in the standard Western range of the Unicode it looks OK any letter out of that range is "?". Changing fonts did not have any impact. In any case I'm using Arial MS Unicode which should have both English, Spanish... |
|
#10
|
|||
|
|||
|
I'm not sure what is causing this but a solution that comes to mind is to use GetPrivateProfileStringA and convert the result with StrConv(result,vbFromUnicode).
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Reading unicode from INI |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|