Ignore:
Timestamp:
Jul 31, 2003, 5:59:49 PM (22 years ago)
Author:
sandervl
Message:

export DBCS environment variable; updated special DBCS string functions to behave differently in SBCS environments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/heapstring.cpp

    r10176 r10191  
    1 /* $Id: heapstring.cpp,v 1.53 2003-07-16 18:07:01 sandervl Exp $ */
     1/* $Id: heapstring.cpp,v 1.54 2003-07-31 15:59:49 sandervl Exp $ */
    22/*
    33 * Project Odin Software License can be found in LICENSE.TXT
     
    486486    //-> overwrites stack
    487487    if(ret == length) {
     488#if 1
     489         lstrtrunc( astring, length );
     490#else
    488491         astring[length-1] = 0;
     492#endif
    489493    }
    490494    else astring[ret] = 0;
     
    619623        ulen = lstrlenW( ustring );
    620624
     625    if( !IsDBCSEnv() ) return ulen;
     626
    621627    ret = WideCharToMultiByte( CP_ACP, 0, ustring, ulen, 0, 0, 0, 0 );
    622628    if(ret == 0) {
     
    663669        alen = strlen( astring );
    664670
     671    if( !IsDBCSEnv() ) return alen;
     672
    665673    ret = MultiByteToWideChar( CP_ACP, 0, astring, alen, 0, 0 );
    666674    if(ret == 0) {
     
    670678
    671679    return ret;
     680}
     681
     682/*****************************************************************************
     683 * NAME
     684 *      lstrtrunc
     685 *
     686 * PURPOSE
     687 *      truncate ansi string
     688 *
     689 * PARAMETERS
     690 *      max - max length of truncated string including null-terminator
     691 *
     692 * RESULT
     693 *   Success
     694 *      return the length of truncated string not including null-terminator
     695 *
     696 *   Failure
     697 *      return 0.
     698 *
     699 * REMARK
     700 *      this function is not Win32 API but helper for convenient.
     701 *
     702 * AUTHOR    : KO Myung-Hun
     703 *****************************************************************************/
     704
     705int WIN32API lstrtrunc( LPSTR astring, int max )
     706{
     707    int i;
     708
     709    if( !astring || ( max < 1 ))
     710        return 0;
     711
     712    astring[ max - 1 ] = 0;
     713
     714    if( !IsDBCSEnv() ) return max;
     715
     716    max = strlen( astring );
     717    for( i = 0; i < max; i++ )
     718        if( IsDBCSLeadByte( astring[ i ]))
     719            i++;
     720
     721    if( i > max )               // broken DBCS lead byte ?
     722        astring[ --max ] = 0;   // then remove DBCS lead byte
     723
     724    return max;
    672725}
    673726
Note: See TracChangeset for help on using the changeset viewer.