#include "UnicodeUpp.h"

namespace WTF {
namespace Unicode {

UChar32 foldCase(UChar32 ch){
	RDUMP("foldcase");
	return (UChar32) Upp::ToLower(ch);
}

int foldCase(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error){
	RDUMP("foldCase");
	Upp::WString source(src,srcLength);
	source=Upp::ToLower(source);
	resultLength=source.End()-source.Begin();
	memcpy(result, source.Begin(), resultLength * sizeof(UChar));
	*error=false;
	return resultLength;
}

int toLower(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error){
	RDUMP("toLower");
	Upp::WString source(src,srcLength);
	RDUMP(source);
	RDUMP((int)source[0]);
	source=Upp::ToLower(source);
	resultLength=source.End()-source.Begin();
	memcpy(result, source.Begin(), resultLength * sizeof(UChar));
	RDUMP(Upp::WString(result,resultLength));
	RDUMP((int)result[0]);
	*error=false;
	return resultLength;
}

int toUpper(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error){
	RDUMP("toUpper");
	Upp::WString source(src,srcLength);
	source=Upp::ToUpper(source);
	resultLength=source.End()-source.Begin();
	memcpy(result, source.Begin(), resultLength * sizeof(UChar));
	*error=false;
	return resultLength;
}

Direction direction(UChar32 c){
	RDUMP("direction");
	return LeftToRight;
}

int umemcasecmp(const UChar* a, const UChar* b, int len){
	Upp::WString a_(a);
	Upp::WString b_(b);
	RDUMP("umemcase");
	return Upp::CompareNoCase(a_,b_); 
}

}
}