1 //+-------------------------------------------------------------------------
2 //
3 //  For conditions of distribution and use, see copyright notice
4 //  in Flashpix.h
5 //
6 //  Copyright (c) 1999 Digital Imaging Group, Inc.
7 //
8 //  Contents:   C++ Base wrapper for PROPVARIANT.
9 //
10 //--------------------------------------------------------------------------
11 
12 #include "pch.cxx"
13 #include <ctype.h>
14 
15 /* right now only US ansi support */
16 EXTERN_C
STDAPI_(UINT)17 STDAPI_(UINT) GetACP(VOID)
18 { return 1252; }  /* Latin 1 (US, Western Europe) */
19 
20 #if DBGPROP
21 
22 BOOLEAN
IsUnicodeString(WCHAR const * pwszname,ULONG cb)23 IsUnicodeString(WCHAR const *pwszname, ULONG cb)
24 {
25     if (cb != 0)
26     {
27   ULONG i, cchDoubleAnsi, cchNull;
28 
29   cchNull = cchDoubleAnsi = 0;
30   for (i = 0; pwszname[i] != (OLECHAR)'\0'; i++)
31   {
32       if ((char) pwszname[i] == '\0' || (char) (pwszname[i] >> 8) == '\0')
33       {
34     cchNull++;
35     if (i > 8 && cchDoubleAnsi > (3*i)/4)
36     {
37         // BUGBUG: This is a heuristic that should NOT be left in
38         // the build for long (even the checked build).
39         //PROPASSERT(!"IsUnicodeString: Suspicious string: double Ansi chars");
40         //return(FALSE);
41         return(TRUE);
42     }
43       }
44       else
45       if (isprint((char) pwszname[i]) && isprint((char) (pwszname[i] >> 8)))
46       {
47     cchDoubleAnsi++;
48       }
49   }
50   if (cchNull < i/4)
51   {
52       // BUGBUG: This is a heuristic that should NOT be left in the
53       // build for long (even the checked build).
54 
55       //BUGBUG: cscdrt stringizes GUIDs, leaving lots of high bytes set.
56       //The DRT needs to change to avoid case mapping problems.
57       //Until then, return TRUE
58       //PROPASSERT(!"IsUnicodeString: Suspicious string: too few zero-extended Ansi chars");
59       //return(FALSE);
60   }
61         // If cb isn't MAXULONG we verify that cb is at least as
62         // big as the string.  We can't check for equality, because
63         // there are some property sets in which the length field
64         // for a string may include several zero padding bytes.
65 
66         PROPASSERT(cb == MAXULONG || (i + 1) * sizeof(WCHAR) <= cb);
67     }
68     return(TRUE);
69 }
70 
71 
72 BOOLEAN
IsAnsiString(CHAR const * pszname,ULONG cb)73 IsAnsiString(CHAR const *pszname, ULONG cb)
74 {
75     if (cb != 0)
76     {
77   ULONG i;
78 
79   for (i = 0; pszname[i] != '\0'; i++)
80   {
81   }
82   if (i == 1 && isprint(pszname[0]) &&
83       ((ULONG) &pszname[8] & 0xfff) == ((ULONG) pszname & 0xfff) &&
84       isprint(pszname[2]) && pszname[3] == '\0' &&
85       isprint(pszname[4]) && pszname[5] == '\0' &&
86       isprint(pszname[6]) && pszname[7] == '\0')
87   {
88       // BUGBUG: This is a heuristic that should NOT be left in the
89       // build for long (even the checked build).
90       PROPASSERT(!"IsAnsiString: Suspicious string: looks like Unicode");
91       return(FALSE);
92   }
93         // If cb isn't MAXULONG we verify that cb is at least as
94         // big as the string.  We can't check for equality, because
95         // there are some property sets in which the length field
96         // for a string may include several zero padding bytes.
97 
98   PROPASSERT(cb == MAXULONG || i + 1 <= cb);
99     }
100     return(TRUE);
101 }
102 #endif
103 
104