* - Sign:
* '-'
* @endcode
+ * @remarks This method has portability issue. @n
+ * When the specified string is nagative number in the ARM architecture, type casting is needed like following code.
+ * @code
+ * char ret;
+ * Int8::Decode(L"-0X20", ret);
+ * SomeOutputFunction(static_cast< signed char >(ret));
+ * @endcode
*/
static result Decode(const String& s, char& ret);
*
* @param[in] ch A Unicode character
*/
- String(const wchar_t ch);
+ String(wchar_t ch);
/**
* Initializes this instance of %String with the specified Unicode string.
wchar_t* pEnd = null;
String str(s);
- if (s[0] == L'-')
+ if (s[0] == L'-' || s[0] == L'+')
{
startIndex = 1;
minLength = 3;
"[%s] The length of s MUST be greater than 0.", GetErrorMessage(E_NUM_FORMAT));
int radix = 0;
+ int startIndex = 0;
+ int minLength = 2;
wchar_t* pEnd = null;
String str(s);
+ if (s[0] == L'-' || s[0] == L'+')
+ {
+ startIndex = 1;
+ minLength = 3;
+ }
+
// Find radix
- if (s[0] == L'#')
+ if (s[startIndex] == L'#')
{
radix = Character::RADIX_HEXADECIMAL;
// Remove '#'
- str.Remove(0, 1);
+ str.Remove(startIndex, 1);
}
- else if (s[0] == L'0' && (s.GetLength() >= 2))
+ else if (s[startIndex] == L'0' && (s.GetLength() >= minLength))
{
- if (s[1] == L'x' || s[1] == L'X')
+ if (s[startIndex + 1] == L'x' || s[startIndex + 1] == L'X')
{
radix = Character::RADIX_HEXADECIMAL;
}
"[%s] The length of s MUST be greater than 0.", GetErrorMessage(E_NUM_FORMAT));
int radix = 0;
+ int startIndex = 0;
+ int minLength = 2;
wchar_t* pEnd = null;
String str(s);
+ if (s[0] == L'-' || s[0] == L'+')
+ {
+ startIndex = 1;
+ minLength = 3;
+ }
+
// Find radix
- if (s[0] == L'#')
+ if (s[startIndex] == L'#')
{
radix = Character::RADIX_HEXADECIMAL;
// Remove '#'
- str.Remove(0, 1);
+ str.Remove(startIndex, 1);
}
- else if (s[0] == L'0' && (s.GetLength() >= 2))
+ else if (s[startIndex] == L'0' && (s.GetLength() >= minLength))
{
- if (s[1] == L'x' || s[1] == L'X')
+ if (s[startIndex + 1] == L'x' || s[startIndex + 1] == L'X')
{
radix = Character::RADIX_HEXADECIMAL;
}
long value = 0;
int radix = 0;
+ int startIndex = 0;
+ int minLength = 2;
wchar_t* pEnd = null;
String str(s);
+ if (s[0] == L'-' || s[0] == L'+')
+ {
+ startIndex = 1;
+ minLength = 3;
+ }
+
// Find radix
- if (s[0] == L'#')
+ if (s[startIndex] == L'#')
{
radix = Character::RADIX_HEXADECIMAL;
// Remove '#'
- str.Remove(0, 1);
+ str.Remove(startIndex, 1);
}
- else if (s[0] == L'0' && (s.GetLength() >= 2))
+ else if (s[startIndex] == L'0' && (s.GetLength() >= minLength))
{
- if (s[1] == L'x' || s[1] == L'X')
+ if (s[startIndex + 1] == L'x' || s[startIndex + 1] == L'X')
{
radix = Character::RADIX_HEXADECIMAL;
}
SysTryReturnVoidResult(NID_BASE, r == E_SUCCESS, E_OUT_OF_MEMORY, "Memory allocation failed.");
}
-String::String(const wchar_t ch)
+String::String(wchar_t ch)
: __capacity(0)
, __length(0)
, __hash(0)