Files
Dario Sassi 01097b15df EgtBasis 2.7a1 :
- aggiunta gestione messaggi da file
- aggiunta gestione lettura/scrittura su file INI con UTF8
- aggiunta gestione file di log.
2025-01-25 12:11:42 +01:00

45 lines
1.7 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2025-2025
//----------------------------------------------------------------------------
// File : IniFile.cpp Data : 24.01.25 Versione : 2.7a1
// Contenuto : Implementazione funzioni lettura/scrittura su INI file con UTF8.
//
//
// Modifiche : 24.01.25 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "StringUtils.h"
using namespace std ;
//----------------------------------------------------------------------------
BOOL
__stdcall EgtGetStringUtf8FromIni( const wchar_t* wsSec, const wchar_t* wsKey,
const wchar_t* wsDef, wchar_t*& wsVal, const wchar_t* wsIniFile)
{
// leggo la stringa dal file INI come ANSI/UTF-8 in WChar e metto in Char
wchar_t szBuffW[_MAX_PATH] ;
int nChar = GetPrivateProfileStringW( wsSec, wsKey, NULL, szBuffW, _MAX_PATH, wsIniFile) ;
if ( nChar <= 0)
wsVal = _wcsdup( wsDef) ;
else {
string sVal = LPSTR( WtoAEX<>( szBuffW, CP_ACP)) ;
wsVal = _wcsdup( stringtoW( sVal)) ;
}
return (( wsVal == nullptr) ? FALSE : TRUE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtWriteStringUtf8ToIni( const wchar_t* wsSec, const wchar_t* wsKey, const wchar_t* wsVal, const wchar_t* wsIniFile)
{
// salvo la stringa nel file INI come ANSI/UTF-8 ma scritta in variabile WChar
string sVal = wstrztoA( wsVal) ;
return WritePrivateProfileStringW( wsSec, wsKey, AtoWEX<>( sVal.data(), CP_ACP), wsIniFile) ;
}