Asian Characters - Chinese - Japanese

darbid

Registered User.
Local time
Today, 01:38
Joined
Jun 26, 2008
Messages
1,428
Asian Characters - reading unicode ini file

I currently have my access forms speaking German and English through the use of an .ini file which has the German and and English text in it.

As i have a couple of Chinese and Japanes people using the forms I thought that if they add their language to the .ini it would work. - Nothing is ever that simply.

They wrote some characters into an .ini as a test. On my computer I cannot see the characters. (i just see junk) I was not worried as I just thought my XP was not set up for Asian charactes but when they open it, they would see them.

It appears that not only can I not see the characters when I open the .ini file but that my XP makes the file "dirty" so that if i then send back my looked at .ini file they cannot see their charactes anymore.

I used notepad to open it. Should I use a "better" viewer.

Has anyone had experience with this?

Other tests I tried.

I thought it might just be the .ini file. So I cut and copied "the junk" from this file into a text box directly in access. But once again it becomes "dirty" and they do not see Asian characters again.

They sent me the same information in a Word doc and I can see the characters in that file. So maybe it is Notepad doing the bad things.
 
Last edited:
I am not sure but don't Japaneses/Chinese Characters need more than 1 byte to define them. That would explain why it works in Word and not in Notepad.

Try checking in the Access Options to make sure that Access will support these character sets.
 
Thanks for your help.

It appears that the problem is that my .ini file is ANSI and at this stage the files that I have received from China are Unicode.

When I was initially opening the files NOTEPAD was opening them with ANSI. This explains the loss of the characters.

I am useing the GetPrivateProfileStringA function (API) to read the .ini file which I have now worked out is only for ANSI and there is a GetPrivateProfileStringW which is for unicode. Although I have not got that to work yet I am praying that that is all my problem is.
 
Well as far as I can work out the problem is that the text files I have are encoded in unicode and I am calling an API function which works for ANSI.

The Code is
Code:
Public Declare Function GetPrivateProfileString _
   Lib "kernel32" Alias "GetPrivateProfileStringA" _
  (ByVal lpSectionName As String, _
   ByVal lpKeyName As Any, _
   ByVal lpDefault As String, _
   ByVal lpbuffurnedString As String, _
   ByVal nBuffSize As Long, _
   ByVal lpFileName As String) As Long
Code:
Public Function ProfileGetItem(sSection As String, _
                                sKeyName As String, _
                                sDefValue As String, _
                                sInifile As String) As String

  'retrieves a value from an ini file
  'corresponding to the section and
  'key name passed.
        
   Dim dwSize As Long
   Dim nBuffSize As Long
   Dim buff As String
  
  'Call the API with the parameters passed.
  'nBuffSize is the length of the string
  'in buff, including the terminating null.
  'If a default value was passed, and the
  'section or key name are not in the file,
  'that value is returned. If no default
  'value was passed (""), then dwSize
  'will = 0 if not found.
  '
  'pad a string large enough to hold the data
   buff = Space$(2048)
   nBuffSize = Len(buff)
   dwSize = GetPrivateProfileString(sSection, _
                                    sKeyName, _
                                    sDefValue, _
                                    buff, _
                                    nBuffSize, _
                                    sInifile)


   If dwSize > 0 Then
      ProfileGetItem = Left$(buff, dwSize)
   End If
   
End Function

This works fine as long as the .ini file is saved with ANSI encoding.

From my reading http://msdn.microsoft.com/en-us/library/ms724353(VS.85).aspx

I should be able to change the GetPrivateProfileStringA for GetPrivateProfileStringW when using a .ini file encoded with unicode. BUt I am getting nothing returned and no errors either.

I have uploaded an example of my text file. I had to change the extension to .txt to upload it. May there is something wrong with that file.
 

Attachments

Users who are viewing this thread

Back
Top Bottom