From fdfc279bea84810e00f9c3b65f6e58785f803486 Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 31 Jan 2022 17:22:12 +0000 Subject: [PATCH] String: Fix logical error in hex parsing code --- modules/juce_core/text/juce_CharacterFunctions.h | 4 ++-- modules/juce_core/text/juce_String.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/juce_core/text/juce_CharacterFunctions.h b/modules/juce_core/text/juce_CharacterFunctions.h index f89dc6112f..764417e69d 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.h +++ b/modules/juce_core/text/juce_CharacterFunctions.h @@ -500,10 +500,10 @@ public: while (! t.isEmpty()) { - auto hexValue = static_cast (CharacterFunctions::getHexDigitValue (t.getAndAdvance())); + auto hexValue = CharacterFunctions::getHexDigitValue (t.getAndAdvance()); if (hexValue >= 0) - result = static_cast (result << 4) | hexValue; + result = static_cast (result << 4) | static_cast (hexValue); } return result; diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index b2102bb6fd..8a00e2835b 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -2467,6 +2467,9 @@ public: expect (String (StringRef ("abc")) == StringRef ("abc")); expect (String ("abc") + StringRef ("def") == "abcdef"); + expect (String ("0x00").getHexValue32() == 0); + expect (String ("0x100").getHexValue32() == 256); + String s2 ("123"); s2 << ((int) 4) << ((short) 5) << "678" << L"9" << '0'; s2 += "xyz";