cpsymbol.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * CP_SYMBOL support
  3. *
  4. * Copyright 2000 Alexandre Julliard
  5. * Copyright 2004 Rein Klazes
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  20. */
  21. #include "wine/asm.h"
  22. #ifdef __ASM_OBSOLETE
  23. #include "unicode.h"
  24. /* return -1 on dst buffer overflow */
  25. int wine_cpsymbol_mbstowcs_obsolete( const char *src, int srclen, WCHAR *dst, int dstlen)
  26. {
  27. int len, i;
  28. if (dstlen == 0) return srclen;
  29. len = dstlen > srclen ? srclen : dstlen;
  30. for (i = 0; i < len; i++)
  31. {
  32. unsigned char c = src[i];
  33. dst[i] = (c < 0x20) ? c : c + 0xf000;
  34. }
  35. if (srclen > len) return -1;
  36. return len;
  37. }
  38. /* return -1 on dst buffer overflow, -2 on invalid character */
  39. int wine_cpsymbol_wcstombs_obsolete( const WCHAR *src, int srclen, char *dst, int dstlen)
  40. {
  41. int len, i;
  42. if (dstlen == 0) return srclen;
  43. len = dstlen > srclen ? srclen : dstlen;
  44. for (i = 0; i < len; i++)
  45. {
  46. if (src[i] < 0x20)
  47. dst[i] = src[i];
  48. else if (src[i] >= 0xf020 && src[i] < 0xf100)
  49. dst[i] = src[i] - 0xf000;
  50. else
  51. return -2;
  52. }
  53. if (srclen > len) return -1;
  54. return len;
  55. }
  56. __ASM_OBSOLETE(wine_cpsymbol_mbstowcs);
  57. __ASM_OBSOLETE(wine_cpsymbol_wcstombs);
  58. #endif /* __ASM_OBSOLETE */