Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.5 KiB

  1. /****************************Module*Header***********************************\
  2. * Module Name: UNIFUNC.C
  3. *
  4. * Module Descripton: Number to string conversion routines for Unicode
  5. *
  6. * Warnings:
  7. *
  8. * Created: 22-Aug-1995
  9. *
  10. * Author: JonPa
  11. \****************************************************************************/
  12. #include <windows.h>
  13. #include "scicalc.h"
  14. #define CCH_DWORD 15 // enough for 9 chars in 2^32 + sign, zterm + slop
  15. //
  16. // NOTE!
  17. //
  18. // Even though this function uses psz++ and psz--,
  19. // **IT IS STILL INTERNATIONAL SAFE!**
  20. //
  21. // That is because we put the chars in the string, and
  22. // we are only ever using chars that are single byte in ALL
  23. // code pages ('0'..'9').
  24. //
  25. TCHAR *UToDecT( UINT value, TCHAR *sz) {
  26. TCHAR szTmp[CCH_DWORD];
  27. LPTSTR psz = szTmp;
  28. LPTSTR pszOut;
  29. do {
  30. *psz++ = TEXT('0') + (value % 10);
  31. value = value / 10;
  32. } while( value != 0 );
  33. for( psz--, pszOut = sz; psz >= szTmp; psz-- )
  34. *pszOut++ = *psz;
  35. *pszOut = TEXT('\0');
  36. return sz;
  37. }
  38. #ifdef UNICODE
  39. # if 0
  40. double MyAtof( const WCHAR *string ) {
  41. char szAnsi[MAX_PATH];
  42. WideCharToMultiByte( CP_ACP, WC_COMPOSITECHECK, string, -1, szAnsi, sizeof(szAnsi), NULL, NULL );
  43. return atof( szAnsi );
  44. }
  45. WCHAR *MyGcvt( double value, int digits, WCHAR *buffer ) {
  46. char szAnsi[MAX_PATH];
  47. _gcvt( value, digits, szAnsi);
  48. MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szAnsi, -1, buffer, MAX_PATH);
  49. return buffer;
  50. }
  51. # endif
  52. #endif