2010-08-27 15:49 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* src/rtl/hbi18n2.prg
  * utils/hbmk2/hbmk2.prg
    + UTF8 BOM logic contained in core. Should fix it for all 
      cases in hbmk2 and hbi18n.
This commit is contained in:
Viktor Szakats
2010-08-27 13:50:20 +00:00
parent 731fb7304f
commit abba013e29
3 changed files with 25 additions and 25 deletions

View File

@@ -16,6 +16,12 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-08-27 15:49 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* src/rtl/hbi18n2.prg
* utils/hbmk2/hbmk2.prg
+ UTF8 BOM logic contained in core. Should fix it for all
cases in hbmk2 and hbi18n.
2010-08-27 15:33 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* src/rtl/hbi18n2.prg
! __I18N_POTARRAYSAVE() typo in BOM flag default.

View File

@@ -299,7 +299,23 @@ FUNCTION __I18N_POTARRAYLOAD( cFile, cErrorMsg )
RETURN aTrans
FUNCTION __I18N_POTARRAYSAVE( cFile, aTrans, cErrorMsg, lVersionNo, lSourceRef, lUTF8BOM )
STATIC FUNCTION IsBOM_UTF8( cFileName )
LOCAL fhnd := FOpen( cFileName, FO_READ )
LOCAL cBuffer
IF fhnd != F_ERROR
cBuffer := Space( Len( _UTF8_BOM ) )
FRead( fhnd, @cBuffer, Len( cBuffer ) )
FClose( fhnd )
IF cBuffer == _UTF8_BOM
RETURN .T.
ENDIF
ENDIF
RETURN .F.
FUNCTION __I18N_POTARRAYSAVE( cFile, aTrans, cErrorMsg, lVersionNo, lSourceRef )
LOCAL aItem
LOCAL hFile
LOCAL lRet, lPlural
@@ -312,14 +328,11 @@ FUNCTION __I18N_POTARRAYSAVE( cFile, aTrans, cErrorMsg, lVersionNo, lSourceRef,
IF ! ISLOGICAL( lSourceRef )
lSourceRef := .T.
ENDIF
IF ! ISLOGICAL( lUTF8BOM )
lUTF8BOM := .F.
ENDIF
lRet := .F.
cEol := hb_eol()
cFlg := "#, c-format" + cEol
cPOT := iif( lUTF8BOM, _UTF8_BOM + cEol, "" ) + ; /* Put it in separate line to less confuse non-BOM aware parsers */
cPOT := iif( hb_FileExists( cFile ) .AND. IsBOM_UTF8( cFile ), _UTF8_BOM + cEol, "" ) + ; /* Put it in separate line to less confuse non-BOM aware parsers */
"#" + cEol + ;
"# This file is generated by " + iif( lVersionNo, hb_version(), "Harbour" ) + cEol + ;
"#" + cEol

View File

@@ -10164,11 +10164,9 @@ STATIC PROCEDURE POTMerge( hbmk, aFiles, cFileBase, cFileOut )
STATIC PROCEDURE AutoTrans( hbmk, cFileIn, aFiles, cFileOut )
LOCAL cErrorMsg
LOCAL lUTF8BOM := IsBOM_UTF8( cFileOut )
IF ! __i18n_potArraySave( cFileOut, ;
__i18n_potArrayTrans( LoadPOTFiles( hbmk, {}, cFileIn, .F. ), ;
LoadPOTFilesAsHash( hbmk, aFiles ) ), @cErrorMsg, ! hbmk[ _HBMK_lMINIPO ], ! hbmk[ _HBMK_lMINIPO ], lUTF8BOM )
LoadPOTFilesAsHash( hbmk, aFiles ) ), @cErrorMsg, ! hbmk[ _HBMK_lMINIPO ], ! hbmk[ _HBMK_lMINIPO ] )
hbmk_OutErr( hbmk, hb_StrFormat( I_( "Error: %1$s" ), cErrorMsg ) )
ENDIF
@@ -10192,23 +10190,6 @@ STATIC FUNCTION GenHBL( hbmk, aFiles, cFileOut, lEmpty )
RETURN lRetVal
#define _UTF8_BOM e"\xEF\xBB\xBF"
STATIC FUNCTION IsBOM_UTF8( cFileName )
LOCAL fhnd := FOpen( cFileName, FO_READ )
LOCAL cBuffer
IF fhnd != F_ERROR
cBuffer := Space( Len( _UTF8_BOM ) )
FRead( fhnd, @cBuffer, Len( cBuffer ) )
FClose( fhnd )
IF cBuffer == _UTF8_BOM
RETURN .T.
ENDIF
ENDIF
RETURN .F.
STATIC FUNCTION win_implib_command( hbmk, cCommand, cSourceDLL, cTargetLib, cFlags )
IF ! hb_FileExists( cSourceDLL )