2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../core/juce_StandardHeader.h"
29 #pragma warning (push)
30 #pragma warning (disable: 4514 4996)
41 #include "juce_String.h"
42 #include "../memory/juce_HeapBlock.h"
44 //==============================================================================
45 juce_wchar
CharacterFunctions::toUpperCase (const juce_wchar character
) noexcept
47 return towupper ((wchar_t) character
);
50 juce_wchar
CharacterFunctions::toLowerCase (const juce_wchar character
) noexcept
52 return towlower ((wchar_t) character
);
55 bool CharacterFunctions::isUpperCase (const juce_wchar character
) noexcept
58 return iswupper ((wchar_t) character
) != 0;
60 return toLowerCase (character
) != character
;
64 bool CharacterFunctions::isLowerCase (const juce_wchar character
) noexcept
67 return iswlower ((wchar_t) character
) != 0;
69 return toUpperCase (character
) != character
;
77 //==============================================================================
78 bool CharacterFunctions::isWhitespace (const char character
) noexcept
80 return character
== ' ' || (character
<= 13 && character
>= 9);
83 bool CharacterFunctions::isWhitespace (const juce_wchar character
) noexcept
85 return iswspace ((wchar_t) character
) != 0;
88 bool CharacterFunctions::isDigit (const char character
) noexcept
90 return (character
>= '0' && character
<= '9');
93 bool CharacterFunctions::isDigit (const juce_wchar character
) noexcept
95 return iswdigit ((wchar_t) character
) != 0;
98 bool CharacterFunctions::isLetter (const char character
) noexcept
100 return (character
>= 'a' && character
<= 'z')
101 || (character
>= 'A' && character
<= 'Z');
104 bool CharacterFunctions::isLetter (const juce_wchar character
) noexcept
106 return iswalpha ((wchar_t) character
) != 0;
109 bool CharacterFunctions::isLetterOrDigit (const char character
) noexcept
111 return (character
>= 'a' && character
<= 'z')
112 || (character
>= 'A' && character
<= 'Z')
113 || (character
>= '0' && character
<= '9');
116 bool CharacterFunctions::isLetterOrDigit (const juce_wchar character
) noexcept
118 return iswalnum ((wchar_t) character
) != 0;
121 int CharacterFunctions::getHexDigitValue (const juce_wchar digit
) noexcept
123 unsigned int d
= digit
- '0';
124 if (d
< (unsigned int) 10)
127 d
+= (unsigned int) ('0' - 'a');
128 if (d
< (unsigned int) 6)
131 d
+= (unsigned int) ('a' - 'A');
132 if (d
< (unsigned int) 6)
138 double CharacterFunctions::mulexp10 (const double value
, int exponent
) noexcept
146 const bool negative
= (exponent
< 0);
148 exponent
= -exponent
;
150 double result
= 1.0, power
= 10.0;
151 for (int bit
= 1; exponent
!= 0; bit
<<= 1)
153 if ((exponent
& bit
) != 0)
163 return negative
? (value
/ result
) : (value
* result
);