This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

WEC7 Problem with SetLocaleInfo

Intellectual 745 points

Replies: 4

Views: 1563

All,

I found an issue with Locales under Windows Embedded Compact 7.  If you select a particular Locale for some country or region, all the default values for currency symbol, decimal point symbol, etc. seem to work fine, however, when we want to customize any settings – we can’t do it.  And we have a need to do so.  There is a new currency symbol in Turkey and we’ve added this symbol to our font set. Then, we’d like to select it as a currency symbol for Turkey, and we cannot do it. Always the default “TL” comes back.  It’s the same with other locale values and other countries too.
It’s been working fine with CE6.0, and with WEC7.0 this functionality is broken.

You can reproduce it by the following steps in WEC7:

1.       Go to Control Panel -> Regional Settings,
2.       Select some other Locale than “English (United States)”,
3.       Press button Customize,
4.       Select tab Currency,
5.       Change Currency symbol,
6.       Press OK,
7.       Press OK to leave the dialog,
8.       Enter Regional Settings from Control Panel Again (select the same Locale as previously), *
9.       Follow steps 3 and 4 to navigate to the Currency tab,
10.      See the previous (default) currency symbol.

* There is another issue with Combo Boxes – basically WEC7 shows Combo Boxes incorrectly – initially they always display the first item.

The root cause of this problem is an API SetLocaleInfo, which doesn’t work correctly. It returns value of 1, but it doesn’t change anything.

Could you please help us with this?
Thank you!
Zack

 

4 Replies

  • All,

    I've installed CEPC BSP and I've built my OS for Virtual PC. With that, I was still able to reproduce this problem, but it looks like there is some workaround for the currently selected locale in the Control Panel with which following my steps I've provided earlier doesn't show any issue. But I was able to reproduce this issue with CEPC by just adding one step to the previous list:

    1.       Go to Control Panel -> Regional Settings,
    2.       Select some other Locale than “English (United States)”,
    3.       Press button Customize,
    4.       Select tab Currency,
    5.       Change Currency symbol,
    6.       Press OK,

    6.5     Change the current Locale back to default (“English (United States)”),

    7.       Press OK to leave the dialog,
    8.       Enter Regional Settings from Control Panel Again (select the same Locale as previously),
    9.       Follow steps 3 and 4 to navigate to the Currency tab,
    10.      See the previous (default) currency symbol.

    Also, you can reproduce it with a simple test application:

    #include "stdafx.h"
    int _tmain(int argc, _TCHAR* argv[])
    {
        LCID dwLocaleID
    = 0x041f;
        LCTYPE dwLcType
    = LOCALE_SCURRENCY;
        WCHAR wcBuffer
    [10] = {0};
       
    int   nBufferSize  = 10;
       
    int   nRet         = 0;
        nRet
    = GetLocaleInfo(dwLocaleID, dwLcType, wcBuffer, nBufferSize);
        wprintf
    (L"Locale 0x%X has the following currency symbol: \"%s\"; GetLocaleInfo returned value: %d\n", dwLocaleID, wcBuffer, nRet);
        swprintf_s
    (wcBuffer, 10, L"L");
        nRet
    = SetLocaleInfo(dwLocaleID, dwLcType, wcBuffer);
        wprintf
    (L"Changed currency symbol to: \"%s\"; SetLocaleInfo returned value: %d\n", wcBuffer, nRet);
        wprintf
    (L"Reading the changed currency symbol...\n");
        nRet
    = GetLocaleInfo(dwLocaleID, dwLcType, wcBuffer, nBufferSize);
        wprintf
    (L"Locale 0x%X has the following currency symbol: \"%s\"; GetLocaleInfo returned value: %d\n", dwLocaleID, wcBuffer, nRet);
        getchar
    ();
       
    return 0;
    }

    It uses locale ID "0x041f", which is Turkey.  To test, it you'll have to add it to your OS image or use a different locale (but not the US one).

     Best regards,

    Zack

     

     

  • In reply to Zack Zadecki:

    All,

    This is na update of this issue:

    I've received information that API SetLocaleInfo for WEC7 (CE7) works only for the currently selected locale and before calling SetLocaleInfo we should select the locale by calling "SetUserDefaultLCID".

    I've tested it on CEPC and I thought I have the issue solved.  However... it turned out that there is another problem - on our platform "SetUserDefaultLCID" always fails and we basically cannot change the current locale, so we cannot change any value for a different locale than we currently have.  The GetLastError call returns 87 (The parameter is incorrect).  We use DM3730 and a custom board similar to the TI's EVM.

    Please let me know if you have any ideas on this.

    Thank you!

    Best regards,

    Zack

     

  • In reply to Zack Zadecki:

    All,

    One more thing. Before I call SetUserDefaultLCID, I check the locale Is using IsValidLocale, so the locale I'm trying to use is supported in the system.

    Please let me know if you have any ideas.

    Thank you!

    Zack

  • In reply to Zack Zadecki:

    OK, I've figured it out.  It looks like the file "locale.nls" has to be in the NK region.  I've had it in the BinFS region and that's why it didn't work.  After moving it to NK, SetUserDefaultLCID works fine.

    Best regards,

    Zack

     

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.