home *** CD-ROM | disk | FTP | other *** search
/ Delphi Developer's Kit 1996 / Delphi Developer's Kit 1996.iso / power / wfc007.000 / src / u2a_a2u.cpp < prev   
Encoding:
C/C++ Source or Header  |  1995-12-22  |  1.1 KB  |  60 lines

  1. #include <wfc.h>
  2. #pragma hdrstop
  3.  
  4. /*
  5. ** Author: Samuel R. Blackburn
  6. ** CI$: 76300,326
  7. ** Internet: sammy@sed.csc.com
  8. **
  9. ** You can use it any way you like.
  10. */
  11.  
  12. #if defined( _DEBUG )
  13. #undef THIS_FILE
  14. static char BASED_CODE THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. void ASCII_to_UNICODE( LPCSTR ansi_string, LPWSTR unicode_string )
  18. {
  19.    if ( ansi_string == NULL || unicode_string == NULL )
  20.    {
  21.       return;
  22.    }
  23.  
  24.    int index = 0;
  25.  
  26.    while( ansi_string[ index ] != 0x00 )
  27.    {
  28.       unicode_string[ index ] = ansi_string[ index ];
  29.       index++;
  30.    }
  31.  
  32.    unicode_string[ index ] = 0;
  33. }
  34.  
  35. void UNICODE_to_ASCII( LPCWSTR unicode_string, LPSTR ansi_string )
  36. {
  37.    if ( unicode_string == (LPCWSTR) NULL || ansi_string == (LPSTR) NULL )
  38.    {
  39.       return;
  40.    }
  41.  
  42.    int index = 0;
  43.  
  44.    while( unicode_string[ index ] != 0 )
  45.    {
  46.       if ( unicode_string[ index ] < 256 )
  47.       {
  48.          ansi_string[ index ] = (char) unicode_string[ index ];
  49.       }
  50.       else
  51.       {
  52.          ansi_string[ index ] = ' ';
  53.       }
  54.  
  55.       index++;
  56.    }
  57.  
  58.    ansi_string[ index ] = 0x00;
  59. }
  60.