[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / UTF16_Encoding_Converter.inl
blobe52927578895bb75aa9aa5eb9364516051645b4b
1 /* -*- C++ -*- */
2 // $Id: UTF16_Encoding_Converter.inl 80826 2008-03-04 14:51:23Z wotte $
4 // ======================================================================
5 //
6 // The actual conversion methods are covered by the copyright information
7 // below.
8 // Chad Elliott 4/28/2005
9 //
10 // Copyright 2001-2004 Unicode, Inc.
12 // Limitations on Rights to Redistribute This Code
14 // Unicode, Inc. hereby grants the right to freely use the information
15 // supplied in this file in the creation of products supporting the
16 // Unicode Standard, and to make copies of this file in any form
17 // for internal or external distribution as long as this notice
18 // remains attached.
20 // ======================================================================
22 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 ACE_INLINE bool
25 ACE_UTF16_Encoding_Converter::is_legal_utf8 (const ACE_Byte* source,
26                                              size_t length) const
28   ACE_Byte a;
29   const ACE_Byte* srcptr = source + length;
31   switch (length)
32     {
33     default:
34       return false;
36     // Everything else falls through when "true"...
37     case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
38     case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
39     case 2: if ((a = (*--srcptr)) > 0xBF) return false;
41     switch (*source)
42       {
43       // no fall-through in this inner switch
44       case 0xE0:
45         if (a < 0xA0)
46           return false;
47         break;
48       case 0xED:
49         if (a > 0x9F)
50           return false;
51         break;
52       case 0xF0:
53         if (a < 0x90)
54           return false;
55         break;
56       case 0xF4:
57         if (a > 0x8F)
58           return false;
59         break;
60       default:
61         if (a < 0x80)
62           return false;
63     }
65     case 1:
66       if (*source >= 0x80 && *source < 0xC2)
67         return false;
68     }
70   if (*source > 0xF4)
71     return false;
73   return true;
76 ACE_END_VERSIONED_NAMESPACE_DECL