Server : Apache/2.4.43 (Win64) OpenSSL/1.1.1g PHP/7.4.6
System : Windows NT USER-PC 6.1 build 7601 (Windows 7 Professional Edition Service Pack 1) AMD64
User : User ( 0)
PHP Version : 7.4.6
Disable Function : NONE
Directory :  C:/xampp/FileZillaFTP/source/interface/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : C:/xampp/FileZillaFTP/source/interface/OutputFormat.cpp
#include "stdafx.h"

#include "OutputFormat.h"


// This function adds delimiters by thousands base.
// Delimiter based on user locale settings.
CString makeUserFriendlyString(__int64 val)
{
	int delimLen = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, NULL, 0);

	CString delimStr;
	delimStr.Preallocate(delimLen);

	::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, delimStr.GetBuffer(), delimLen);
	delimStr.ReleaseBuffer();

	CString str;
	str.Format(_T("%I64d"), val);

	CString result_str;
	int dec_count = 2 - ((str.GetLength() + 2) % 3);
	for (int idx = 0; idx < str.GetLength(); idx++)
	{
		if (dec_count > 2)
		{
			dec_count = 0;
			result_str += delimStr;
		}
		result_str += str[idx];
		dec_count++;
	}
	return result_str;
}