So, I have been trying to convert IANA timezone to windows ID in c++. Here is my sample code.
#include <ucal.h>
#include <wchar.h>
#include <string.h>
int main()
{
wchar_t buffer[128];
UErrorCode status;;
DWORD dwResult = 0;
DWORD iterator = 0;
DYNAMIC_TIME_ZONE_INFORMATION dynamicTimezone = { 0 };
DWORD i = 0;
printf("\n\n\n");
int length = 128;
char tz_info[128] = "America/New_York";
size_t len = strlen(tz_info) + 1;
wchar_t text_wchar[128];
mbstowcs_s(0, text_wchar, len, tz_info, _TRUNCATE);
auto result = ucal_getWindowsTimeZoneID(text_wchar, -1, buffer, ARRAYSIZE(buffer), &status);
if (U_SUCCESS(status)) {
printf("result = %d, Windows %ls:%s <- IANA %ls\n",
result, buffer, "None", text_wchar);
}
else {
printf("FAILED");
}
return 0;
}
Now that above code works when I use "icu.h" header and include the system libraries icuuc.lib and icuin.lib. However, in my project, I would like to use a custom build icu (v63), but when I use the custom built .libs
and .dlls
the function returns a result length of 0 and there is nothing in buffer.
I did not find many resources on how to use custom built icu for timezone conversions. Is there anything else that needs to be done or added? Do we need to specify or load data files separately?
I am not sure if data files needs to be loaded separately, I think they are loaded with icudt.lib
and icudt.dll
file.
TIA.