Opc.Ua.Com.ComUtils.CompareLocales C# (CSharp) Method

CompareLocales() public static method

Compares a string locale to a WIN32 localeId
public static CompareLocales ( int localeId, string locale, bool ignoreRegion ) : bool
localeId int
locale string
ignoreRegion bool
return bool
		public static bool CompareLocales(int localeId, string locale, bool ignoreRegion)
		{
            // parse locale.
            CultureInfo culture = null;

			try   
			{ 
                culture = new CultureInfo(locale);
			}
			catch (Exception)
			{ 
                return false;
			}

            // only match the language portion of the locale id.
            if (ignoreRegion)
            {
                if ((localeId & culture.LCID & 0x3FF) == (localeId & 0x3FF))
                {
                    return true;
                }
            }

            // check for exact match.
            else
            {   
                if (localeId == culture.LCID)
                {
                    return true;
                }
            }

			return false; 
		}