If you write a string to a file using File.replaceWithText and then compare the result from File.loadFileAsString with your original string they may not be equal due to newline differences. How about adding a compareIgnoreNewlines method to String and CharacterFunctions to get around this?
[code] bool isNewline (const juce_wchar character)
{
const char c = (char) character;
return (c <= 13 && c >= 10);
}
int compareIgnoreNewlines(const juce_wchar* s1, const juce_wchar* s2) {
for (;;)
{
while (isNewline(*s1))
++s1;
while (isNewline(*s2))
++s2;
if (*s1 != *s2)
{
const int diff = *s1 - *s2;
if (diff != 0)
return diff < 0 ? -1 : 1;
}
else if (*s1 == 0)
break;
++s1;
++s2;
}
return 0;
}[/code]
Cheers,
Caleb