Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cyrillic to app.ini as Unicode
Message
De
23/01/2013 08:02:39
 
 
À
23/01/2013 07:09:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01563723
Message ID:
01563746
Vues:
129
This message has been marked as the solution to the initial question of the thread.
J'aime (1)
>>ooops, wrong ....
>>CPCURRENT() ... 1250
>>CPCURRENT(1) .... 1250
>
>
>>LOCAL c
>>c=strconv(filetostr("app.ini"),6, 1251,1)
>>alines(aR, c)
>>...
>****************
>>the problem is the opposite direction: from the VFP textbox (fontcharset=204) to App.ini, so that when I open the app.ini with notepad, see the Cyrillic alphabet, in certain sections.
>
>>In that case, try
>
>>xx = rtrim(thisform.text1.Value) && or for this example xx = strconv('CFE5F0E020CFE5F0E89E', 16)
>>yy = strconv(m.xx, 5, 1251, 1)
>>=strtofile(m.yy, 'd:\tmp\1.txt', 2) && with BOM marker
>>I can open the file with notepad and it displays the chars Пера Перић
>
>Congratulations to Greg.
>I can open the file with notepad and it displays the chars Пера Перић. That is ok.
>
>I just do not need to write to d:\ temp\1.txt, but in App.ini
>section Firma
>Director = Пера Перић

This seems to work

( to read the value, suggest you use GetPrivateProfileStringW ( http://msdn.microsoft.com/en-us/library/ms724353(v=vs.85).aspx )
function do_it()

	local iniFile 
	local section
	local key
	local value
	
	iniFile = 'd:\tmp\app.ini'
	section = 'Firma' 
	key = 'Director'
	value = strconv('CFE5F0E020CFE5F0E89E', 16)
	
	
	if( WritePrivateProfileStringUnicode( ;
				m.section, ;
				m.key, ;
				m.value, ;
				1251, ;
				m.iniFile ;
				) ;
		)
		? 'OK'
	else
		? 'Fail'
	endif
	
endfunc
*_______________________________________________________________________________
function WritePrivateProfileStringUnicode as Boolean
	lparameters ;
				section as String, ;
				key as String, ;
				value as String, ;
				codepage as Integer, ;
				iniFile as String
	
	section = strconv(m.section+ chr(0), 5, m.codepage, 1)
	
	key  = strconv(m.key+ chr(0) , 5, m.codepage, 1)
	value = strconv(m.value + chr(0), 5, m.codepage, 1)
	iniFile = strconv(m.iniFile+ chr(0) , 5, m.codepage, 1)
	
	return !empty(WritePrivateProfileStringW( ;
					@m.section, ;
					@m.key, ;
					@m.value, ;
					@m.inifile ;
					) ;
				)

endfunc
*_______________________________________________________________________________
function WritePrivateProfileStringW (section, key, value, inifile)

	local returnValue
	
	try
		declare integer WritePrivateProfileStringW in kernel32.dll ;
			string@ lpAppName, ;
	  		string@ lpKeyName, ;
	  		string@ lpString, ;
	  		string@ lpFileName 
	  	
	  	returnValue = WritePrivateProfileStringW( ;
		  			@m.section, ;
		  			@m.key, ;
		  			@m.value, ;
		  			@m.inifile ;
	  			)
	 catch
	 	assert .f.
	 	returnValue = 0
	 endtry
	 
	 return m.returnValue
endfunc
*_______________________________________________________________________________
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform