Changeset 83 for trunk/src


Ignore:
Timestamp:
Jun 9, 1999, 10:16:53 PM (26 years ago)
Author:
phaller
Message:

Fix: various unicode fixes

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/NTDLL/rtlstr.cpp

    r56 r83  
    22 * Project Odin Software License can be found in LICENSE.TXT
    33 * Win32 NT Runtime / NTDLL for OS/2
    4  *
    5  * Copyright 1998       original WINE Author
    6  * Copyright 1998, 1999 Patrick Haller (phaller@gmx.net)
    7  *
    84 * Rtl string functions
    95 *
    106 * Copyright 1996-1998 Marcus Meissner
     7 * Copyright 1998, 1999 Patrick Haller (phaller@gmx.net)
    118 */
    129
     
    1613#include <string.h>
    1714#include <ctype.h>
     15
     16#include <os2win.h>
     17#include <unicode.h>
    1818
    1919#include "ntdll.h"
     
    6161    return STATUS_BUFFER_OVERFLOW;
    6262
    63   lstrcpynAtoW(uni->Buffer,ansi->Buffer,unilen/2);
     63  AsciiToUnicodeN(ansi->Buffer,
     64                  uni->Buffer,
     65                  unilen/2);
    6466
    6567  return STATUS_SUCCESS;
     
    99101    return STATUS_BUFFER_OVERFLOW;
    100102
    101   lstrcpynAtoW(uni->Buffer,
    102                ansi->Buffer,
     103  AsciiToUnicodeN(ansi->Buffer,
     104               uni->Buffer,
    103105               unilen/2);
    104106  return STATUS_SUCCESS;
     
    135137                      (len+1)*sizeof(WCHAR));
    136138
    137   lstrcpynAtoW(x,
    138                oemstr,
    139                len+1);
     139  AsciiToUnicodeN(oemstr,
     140                  x,
     141                  len+1);
    140142
    141143  memcpy(unistr,
     
    178180                      (len+1)*sizeof(WCHAR));
    179181
    180   lstrcpynAtoW(x,
    181                oemstr,
    182                len+1);
     182  AsciiToUnicodeN(oemstr,
     183                  x,
     184                  len+1);
    183185
    184186  memcpy(unistr,
     
    214216
    215217/**************************************************************************
    216  *                 RtlInitOemString           
     218 *                 RtlInitOemString
    217219 */
    218220VOID WINAPI RtlInitOemString(POEM_STRING target,
     
    348350                     len+1);
    349351
    350   lstrcpynWtoA(x,
    351                unistr,
    352                len+1);
     352  UnicodeToAsciiN(unistr,
     353                  x,
     354                  len+1);
    353355
    354356  memcpy(oemstr,
     
    384386
    385387  oem->Length = uni->Length/2;
    386   lstrcpynWtoA(oem->Buffer,
    387                uni->Buffer,
    388                uni->Length/2+1);
     388  UnicodeToAsciiN(uni->Buffer,
     389                  oem->Buffer,
     390                  oem->MaximumLength);
    389391  return 0;
    390392}
     
    411413
    412414  oem->Length = uni->Length/2;
    413   lstrcpynWtoA(oem->Buffer,
    414                uni->Buffer,
    415                uni->Length/2+1);
     415  UnicodeToAsciiN(uni->Buffer,
     416                  oem->Buffer,
     417                  oem->MaximumLength);
    416418
    417419  return 0;
  • trunk/src/kernel32/unicode.cpp

    r81 r83  
    11/*
    2  *
    32 * Project Odin Software License can be found in LICENSE.TXT
    4  *
    5  */
    6 /*
    73 * Unicode functions
    8  *
    94 * Copyright 1998 Joel Troster
    10  *
     5 * Copyright 1999 Patrick haller
    116 */
    127#include <os2win.h>
     
    136131  }
    137132  else
    138   {
    139    for(i = 0; i < unilen; i++) {
    140         astring[i] = (char)ustring[i];
    141    }
    142    astring[unilen] = 0;
    143   }
     133   /* idiots unicode conversion :) */
     134   for(i = 0; i < unilen; i++)
     135     astring[i] = (char)ustring[i];
     136
     137  astring[unilen] = 0; // @@@PH: 1999/06/09 fix - always terminate string
     138
    144139  return(unilen);
    145140}
     
    217212
    218213  unicode[asciilen] = 0;
     214//SvL: Messes up the heap
     215//  unicode[len+1] = 0; /* @@@PH 98/06/07 */
    219216}
    220217//******************************************************************************
  • trunk/src/user32/RESSTRING.C

    r46 r83  
    2323#include "unicode.h"
    2424
    25 static char *UnicodeToAsciiN(WCHAR *wstring, char *astring, int maxlen);
    26 
    2725/******************************************************************************/
    28 //Strings stored as original: WORD    len 
     26//Strings stored as original: WORD    len
    2927//                            UNICODE string (not null terminated)
    3028/******************************************************************************/
    31 int OS2LoadStringAscii(HINSTANCE hinst, UINT wID, LPSTR lpBuffer, int cchBuffer)
     29int OS2LoadStringAscii(HINSTANCE hinst,
     30                       UINT      wID,
     31                       LPSTR     lpBuffer,
     32                       int       cchBuffer)
    3233{
    33  APIRET  rc;
    34  WCHAR  *szbuf;
    35  char    modname[128];
    36  HMODULE hmodule;
     34  APIRET  rc;
     35  WCHAR  *szbuf;
     36  char    modname[128];
     37  HMODULE hmodule;
    3738
    38   if(hinst != 0 && hinst != -1) {
    39         if(Win32QueryModuleName(hinst, modname, sizeof(modname)) == 0) {
    40 #ifdef DEBUG
    41                 WriteLog("Can't determine handle of dll %X\n", hinst);
    42 #endif
    43                 return(0);
    44         }
    45         rc = DosQueryModuleHandle(modname, &hmodule);
    46         if(rc) {
    47 #ifdef DEBUG
    48                 WriteLog("Can't determine handle of dll %s\n", modname);
    49 #endif
    50                 return(0);
    51         }
     39  if(hinst != 0 && hinst != -1)
     40  {
     41    if(Win32QueryModuleName(hinst,
     42                            modname,
     43                            sizeof(modname)) == 0)
     44    {
     45      dprintf(("USER32: OS2LoadStringAscii: Can't determine handle of dll %08xh\n",
     46               hinst));
     47      return(0);
     48   }
     49
     50   rc = DosQueryModuleHandle(modname,
     51                             &hmodule);
     52   if(rc)
     53   {
     54     dprintf(("USER32: OS2LoadStringAscii: Can't determine handle of dll %s\n",
     55              modname));
     56
     57     return(0);
     58   }
    5259  }
    53   else  hmodule = 0;
     60  else
     61    hmodule = 0;
    5462
    55   rc = DosGetResource(hmodule, RT_RCDATA, wID, (PPVOID)&szbuf);
    56   if(rc) {
    57 #ifdef DEBUG
    58         WriteLog("OS2LoadString failed with rc %d\n", rc);
    59 #endif
    60         if(lpBuffer)    *lpBuffer = 0;
    61         return(0);      //TODO: SetLastError!
     63  rc = DosGetResource(hmodule,
     64                      RT_RCDATA,
     65                      wID,
     66                      (PPVOID)&szbuf);
     67  if(rc)
     68  {
     69    dprintf(("USER32: OS2LoadStringAscii failed with rc %08xh\n",
     70             rc));
     71
     72    if(lpBuffer)
     73      *lpBuffer = 0;
     74
     75    return(0);  //TODO: SetLastError!
    6276  }
    63   UnicodeToAsciiN(szbuf+1, lpBuffer, min((*szbuf), cchBuffer-1));
    64 #ifdef DEBUG
    65   WriteLog("OS2LoadString retrieved string '%s' (size %d)\n", lpBuffer, (int)*szbuf);
    66 #endif
     77
     78  UnicodeToAsciiN(szbuf+1,
     79                  lpBuffer,
     80                  min((*szbuf), cchBuffer-1));
     81
     82  dprintf(("USER32: OS2LoadStringA retrieved string '%s' (size %d)\n",
     83           lpBuffer,
     84           (int)*szbuf));
     85
    6786  DosFreeResource(szbuf);
    68   return(strlen(lpBuffer));     //not including null terminator!
     87  return(strlen(lpBuffer));              //not including null terminator!
    6988}
    7089//******************************************************************************
    7190//******************************************************************************
    72 int OS2LoadStringUnicode(HINSTANCE hinst, UINT wID, WCHAR *lpBuffer, int cchBuffer)
     91int OS2LoadStringUnicode(HINSTANCE hinst,
     92                         UINT      wID,
     93                         WCHAR     *lpBuffer,
     94                         int       cchBuffer)
    7395{
    74  APIRET  rc;
    75  WCHAR  *szbuf;
    76  char    modname[128];
    77  HMODULE hmodule;
     96  APIRET  rc;
     97  WCHAR  *szbuf;
     98  char    modname[128];
     99  HMODULE hmodule;
     100
    78101#ifdef DEBUG
    79102 char   *astring;
    80103#endif
    81104
    82   if(hinst != 0 && hinst != -1) {
    83         if(Win32QueryModuleName(hinst, modname, sizeof(modname)) == 0) {
    84 #ifdef DEBUG
    85                 WriteLog("Can't determine handle of dll %X\n", hinst);
    86 #endif
    87                 return(0);
    88         }
    89         rc = DosQueryModuleHandle(modname, &hmodule);
    90         if(rc) {
    91 #ifdef DEBUG
    92                 WriteLog("Can't determine handle of dll %s\n", modname);
    93 #endif
    94                 return(0);
    95         }
     105  if(hinst != 0 && hinst != -1)
     106  {
     107    if(Win32QueryModuleName(hinst,
     108                            modname,
     109                            sizeof(modname)) == 0)
     110    {
     111      dprintf(("USER32: OS2LoadStringUnicode: Can't determine handle of dll %08xh\n",
     112               hinst));
     113      return(0);
     114   }
     115
     116   rc = DosQueryModuleHandle(modname,
     117                             &hmodule);
     118   if(rc)
     119   {
     120     dprintf(("USER32: OS2LoadStringUnicode: Can't determine handle of dll %s\n",
     121              modname));
     122
     123     return(0);
     124   }
    96125  }
    97   else  hmodule = 0;
     126  else
     127    hmodule = 0;
    98128
    99   rc = DosGetResource(hmodule, RT_RCDATA, wID, (PPVOID)&szbuf);
    100   if(rc) {
    101 #ifdef DEBUG
    102         WriteLog("OS2LoadString failed with rc %d\n", rc);
    103 #endif
    104         if(lpBuffer)    *lpBuffer = 0;
    105         return(0);      //TODO: SetLastError!
     129  rc = DosGetResource(hmodule,
     130                      RT_RCDATA,
     131                      wID,
     132                      (PPVOID)&szbuf);
     133  if(rc)
     134  {
     135    dprintf(("USER32: OS2LoadStringUnicode failed with rc %08xh\n",
     136             rc));
     137
     138    if(lpBuffer)
     139      *lpBuffer = 0;
     140
     141    return(0);  //TODO: SetLastError!
    106142  }
    107   memcpy(lpBuffer, szbuf+1, min((*szbuf), cchBuffer-1)*sizeof(WCHAR));
     143
     144
     145  memcpy(lpBuffer,
     146         szbuf+1,
     147         min((*szbuf), cchBuffer-1) * sizeof(WCHAR));
     148
    108149  lpBuffer[min((*szbuf), cchBuffer-1)] = 0;
    109150
    110151#ifdef DEBUG
    111152  astring = UnicodeToAsciiString(lpBuffer);
    112   WriteLog("OS2LoadStringW retrieved string '%s' of size %d\n", astring, (int)*szbuf);
     153  WriteLog("USER32: OS2LoadStringUnicode retrieved string '%s' of size %d\n",
     154           astring,
     155           (int)*szbuf);
    113156  FreeAsciiString(astring);
    114157#endif
     158
    115159  DosFreeResource(szbuf);
    116   return(UniStrlen(lpBuffer));  //not including null terminator!
     160  return(UniStrlen(lpBuffer));           //not including null terminator!
    117161}
    118 //******************************************************************************
    119 //******************************************************************************
    120 static char *UnicodeToAsciiN(WCHAR *wstring, char *astring, int maxlen)
    121 {
    122  int i;
    123162
    124   for(i=0;i<maxlen;i++) {
    125         astring[i] = (UCHAR)wstring[i];
    126   }
    127   astring[maxlen] = 0;
    128   return(astring);
    129 }
    130 /******************************************************************************/
    131 /******************************************************************************/
    132 
Note: See TracChangeset for help on using the changeset viewer.