Changeset 257 for trunk/src


Ignore:
Timestamp:
Jun 30, 1999, 11:19:42 PM (26 years ago)
Author:
sandervl
Message:

Fixes for unicode apps

File:
1 edited

Legend:

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

    r250 r257  
    1 /* $Id: unicode.cpp,v 1.10 1999-06-30 13:25:01 sandervl Exp $ */
     1/* $Id: unicode.cpp,v 1.11 1999-06-30 21:19:42 sandervl Exp $ */
    22
    33/*
     
    140140    }
    141141
    142     uni_chars_left = unilen; //elements
    143     out_bytes_left = unilen; //size in bytes
     142    uni_chars_left = unilen-1; //elements
     143    out_bytes_left = uni_chars_left; //size in bytes == elements
    144144    in_buf  = (UniChar*)ustring;
    145145    out_buf = astring;
     
    149149                         &num_subs);
    150150
     151    unilen -= 1+out_bytes_left; //end + left bytes
     152    astring[unilen] = 0; //terminate
     153
     154    return unilen;
     155
    151156//    dprintf(("KERNEL32: UnicodeToAsciiN(%d) '%s'\n", rc, astring ));
    152157  } else
    153158  {
    154159    /* idiots unicode conversion :) */
    155     for(i = 0; i < unilen-1; i++)
     160    for (i = 0; i < unilen-1; i++)
    156161    {
    157162      astring[i] = (ustring[i] > 255) ? (char)20 : (char)ustring[i]; //CB: handle invalid characters as space
    158163      if (ustring[i] == 0) return i; //asta la vista, baby
    159164    }
    160   }
    161 
    162   astring[unilen-1] = 0; // @@@PH: 1999/06/09 fix - always terminate string
    163 
    164   return(unilen-1);
     165
     166    astring[unilen-1] = 0; // @@@PH: 1999/06/09 fix - always terminate string
     167
     168    return(unilen-1);
     169  }
    165170}
    166171//******************************************************************************
     
    232237
    233238    in_buf        = ascii;
    234     in_bytes_left = asciilen; //buffer size in bytes
     239    in_bytes_left = asciilen-1; //buffer size in bytes
    235240    out_buf = (UniChar*)unicode;
    236241
    237     uni_chars_left = asciilen; //elements
     242    uni_chars_left = in_bytes_left; //elements
    238243    dprintf(("KERNEL32: AsciiToUnicode %d\n", in_bytes_left));
    239244
     
    243248                        &num_subs );
    244249
     250    unicode[asciilen-1-in_bytes_left] = 0;
     251
    245252    //if (rc != ULS_SUCCESS && in_bytes_left > 0) //CB: never the case during my tests
    246253    //   dprintf(("KERNEL32: AsciiToUnicode failed, %d bytes left!\n",in_bytes_left));
     
    254261      if (ascii[i] == 0) return; //work done
    255262    }
    256   }
    257 
    258   unicode[asciilen-1] = 0;
     263
     264    unicode[asciilen-1] = 0;
     265  }
    259266}
    260267//******************************************************************************
     
    279286
    280287
     288
Note: See TracChangeset for help on using the changeset viewer.