how to get language of operating system is double byte in delphi?
I want to detect the language of operating system is double byte or not.
to get the language i am using GetLocaleInfo function of windows. But i want to detect is language double byte or not. I can do this with taking name of language and decide is it double byte or not (i.e if language is Japanese then its double byte) but is there any other way to directly get is operating system double byte language or not.
code i am using to get language:
procedure GetLanguage();
var
Buffer : PChar;
Size : integer;
begin
Size := GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, nil, 0);
GetMem(Buffer, Size);
try
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, Buffer, Size);
Writeln(Buffer);
finally
FreeMem(Buffer);
end;
end;
delphi winapi delphi-10.1-berlin
add a comment |
I want to detect the language of operating system is double byte or not.
to get the language i am using GetLocaleInfo function of windows. But i want to detect is language double byte or not. I can do this with taking name of language and decide is it double byte or not (i.e if language is Japanese then its double byte) but is there any other way to directly get is operating system double byte language or not.
code i am using to get language:
procedure GetLanguage();
var
Buffer : PChar;
Size : integer;
begin
Size := GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, nil, 0);
GetMem(Buffer, Size);
try
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, Buffer, Size);
Writeln(Buffer);
finally
FreeMem(Buffer);
end;
end;
delphi winapi delphi-10.1-berlin
GetCPInfoEx(CP_ACP, 0, CpInfo);
NotSingleByte := CpInfo.MaxCharSize > 1
. OrTEncoding.GetEncoding(CP_ACP).IsSingleByte
. I think it depends on what you mean by language of operating system.
– Sertac Akyuz
Nov 20 '18 at 10:59
It's unclear, what "double byte" means to you. Windows uses UTF-16 as its character encoding. Every code point is thus encoded in 2 or 4 bytes. It's also unclear why you need to know (whatever it is). What are you going to do with that information?
– IInspectable
Nov 20 '18 at 11:43
add a comment |
I want to detect the language of operating system is double byte or not.
to get the language i am using GetLocaleInfo function of windows. But i want to detect is language double byte or not. I can do this with taking name of language and decide is it double byte or not (i.e if language is Japanese then its double byte) but is there any other way to directly get is operating system double byte language or not.
code i am using to get language:
procedure GetLanguage();
var
Buffer : PChar;
Size : integer;
begin
Size := GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, nil, 0);
GetMem(Buffer, Size);
try
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, Buffer, Size);
Writeln(Buffer);
finally
FreeMem(Buffer);
end;
end;
delphi winapi delphi-10.1-berlin
I want to detect the language of operating system is double byte or not.
to get the language i am using GetLocaleInfo function of windows. But i want to detect is language double byte or not. I can do this with taking name of language and decide is it double byte or not (i.e if language is Japanese then its double byte) but is there any other way to directly get is operating system double byte language or not.
code i am using to get language:
procedure GetLanguage();
var
Buffer : PChar;
Size : integer;
begin
Size := GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, nil, 0);
GetMem(Buffer, Size);
try
GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, Buffer, Size);
Writeln(Buffer);
finally
FreeMem(Buffer);
end;
end;
delphi winapi delphi-10.1-berlin
delphi winapi delphi-10.1-berlin
edited Nov 20 '18 at 11:08
David Heffernan
519k348221214
519k348221214
asked Nov 20 '18 at 8:29
user10053091
GetCPInfoEx(CP_ACP, 0, CpInfo);
NotSingleByte := CpInfo.MaxCharSize > 1
. OrTEncoding.GetEncoding(CP_ACP).IsSingleByte
. I think it depends on what you mean by language of operating system.
– Sertac Akyuz
Nov 20 '18 at 10:59
It's unclear, what "double byte" means to you. Windows uses UTF-16 as its character encoding. Every code point is thus encoded in 2 or 4 bytes. It's also unclear why you need to know (whatever it is). What are you going to do with that information?
– IInspectable
Nov 20 '18 at 11:43
add a comment |
GetCPInfoEx(CP_ACP, 0, CpInfo);
NotSingleByte := CpInfo.MaxCharSize > 1
. OrTEncoding.GetEncoding(CP_ACP).IsSingleByte
. I think it depends on what you mean by language of operating system.
– Sertac Akyuz
Nov 20 '18 at 10:59
It's unclear, what "double byte" means to you. Windows uses UTF-16 as its character encoding. Every code point is thus encoded in 2 or 4 bytes. It's also unclear why you need to know (whatever it is). What are you going to do with that information?
– IInspectable
Nov 20 '18 at 11:43
GetCPInfoEx(CP_ACP, 0, CpInfo);
NotSingleByte := CpInfo.MaxCharSize > 1
. Or TEncoding.GetEncoding(CP_ACP).IsSingleByte
. I think it depends on what you mean by language of operating system.– Sertac Akyuz
Nov 20 '18 at 10:59
GetCPInfoEx(CP_ACP, 0, CpInfo);
NotSingleByte := CpInfo.MaxCharSize > 1
. Or TEncoding.GetEncoding(CP_ACP).IsSingleByte
. I think it depends on what you mean by language of operating system.– Sertac Akyuz
Nov 20 '18 at 10:59
It's unclear, what "double byte" means to you. Windows uses UTF-16 as its character encoding. Every code point is thus encoded in 2 or 4 bytes. It's also unclear why you need to know (whatever it is). What are you going to do with that information?
– IInspectable
Nov 20 '18 at 11:43
It's unclear, what "double byte" means to you. Windows uses UTF-16 as its character encoding. Every code point is thus encoded in 2 or 4 bytes. It's also unclear why you need to know (whatever it is). What are you going to do with that information?
– IInspectable
Nov 20 '18 at 11:43
add a comment |
1 Answer
1
active
oldest
votes
What do you call "double byte"? Do you mean that when using AnsiString, it may have characters encoded with two AnsiChar?
Use the following code:
FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0;
Edited, since SysLocale.FarEast
is forced to true on Unicode Delphi.
OS support double byte character but my question is about the language of OS is Japanese then its double byte character language and if language is English then it's not double byte character language. your answer gives me is user32.dll support double byte character or not. I debug with your ans. but value of SysLocale.FarEast is true in both cases of Japanese and English O.S.(operating system) which is because it's do support DBCS. @Arnaud
– user10053091
Nov 20 '18 at 10:12
you are right in newest Delphi there is: {$IF DEFINED(UNICODE)} SysLocale.FarEast := True; {$ELSE} SysLocale.FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0; {$ENDIF} Which IMHO is not correct, as used for Ansi*() functions. So I edited my answer, which was correct on older Delphi. Thanks for the feedback!
– Arnaud Bouchez
Nov 20 '18 at 11:08
SM_DBCSENABLED Nonzero if User32.dll supports DBCS; otherwise, 0. It is working, thank you @Arnaud. one question is will it work for 64 bit OS too or do we need to make changes?
– user10053091
Nov 20 '18 at 12:10
on my PC, it works on 64 bit too
– Arnaud Bouchez
Nov 20 '18 at 14:11
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388929%2fhow-to-get-language-of-operating-system-is-double-byte-in-delphi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
What do you call "double byte"? Do you mean that when using AnsiString, it may have characters encoded with two AnsiChar?
Use the following code:
FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0;
Edited, since SysLocale.FarEast
is forced to true on Unicode Delphi.
OS support double byte character but my question is about the language of OS is Japanese then its double byte character language and if language is English then it's not double byte character language. your answer gives me is user32.dll support double byte character or not. I debug with your ans. but value of SysLocale.FarEast is true in both cases of Japanese and English O.S.(operating system) which is because it's do support DBCS. @Arnaud
– user10053091
Nov 20 '18 at 10:12
you are right in newest Delphi there is: {$IF DEFINED(UNICODE)} SysLocale.FarEast := True; {$ELSE} SysLocale.FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0; {$ENDIF} Which IMHO is not correct, as used for Ansi*() functions. So I edited my answer, which was correct on older Delphi. Thanks for the feedback!
– Arnaud Bouchez
Nov 20 '18 at 11:08
SM_DBCSENABLED Nonzero if User32.dll supports DBCS; otherwise, 0. It is working, thank you @Arnaud. one question is will it work for 64 bit OS too or do we need to make changes?
– user10053091
Nov 20 '18 at 12:10
on my PC, it works on 64 bit too
– Arnaud Bouchez
Nov 20 '18 at 14:11
add a comment |
What do you call "double byte"? Do you mean that when using AnsiString, it may have characters encoded with two AnsiChar?
Use the following code:
FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0;
Edited, since SysLocale.FarEast
is forced to true on Unicode Delphi.
OS support double byte character but my question is about the language of OS is Japanese then its double byte character language and if language is English then it's not double byte character language. your answer gives me is user32.dll support double byte character or not. I debug with your ans. but value of SysLocale.FarEast is true in both cases of Japanese and English O.S.(operating system) which is because it's do support DBCS. @Arnaud
– user10053091
Nov 20 '18 at 10:12
you are right in newest Delphi there is: {$IF DEFINED(UNICODE)} SysLocale.FarEast := True; {$ELSE} SysLocale.FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0; {$ENDIF} Which IMHO is not correct, as used for Ansi*() functions. So I edited my answer, which was correct on older Delphi. Thanks for the feedback!
– Arnaud Bouchez
Nov 20 '18 at 11:08
SM_DBCSENABLED Nonzero if User32.dll supports DBCS; otherwise, 0. It is working, thank you @Arnaud. one question is will it work for 64 bit OS too or do we need to make changes?
– user10053091
Nov 20 '18 at 12:10
on my PC, it works on 64 bit too
– Arnaud Bouchez
Nov 20 '18 at 14:11
add a comment |
What do you call "double byte"? Do you mean that when using AnsiString, it may have characters encoded with two AnsiChar?
Use the following code:
FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0;
Edited, since SysLocale.FarEast
is forced to true on Unicode Delphi.
What do you call "double byte"? Do you mean that when using AnsiString, it may have characters encoded with two AnsiChar?
Use the following code:
FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0;
Edited, since SysLocale.FarEast
is forced to true on Unicode Delphi.
edited Nov 20 '18 at 11:07
answered Nov 20 '18 at 9:33
Arnaud BouchezArnaud Bouchez
37.3k356135
37.3k356135
OS support double byte character but my question is about the language of OS is Japanese then its double byte character language and if language is English then it's not double byte character language. your answer gives me is user32.dll support double byte character or not. I debug with your ans. but value of SysLocale.FarEast is true in both cases of Japanese and English O.S.(operating system) which is because it's do support DBCS. @Arnaud
– user10053091
Nov 20 '18 at 10:12
you are right in newest Delphi there is: {$IF DEFINED(UNICODE)} SysLocale.FarEast := True; {$ELSE} SysLocale.FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0; {$ENDIF} Which IMHO is not correct, as used for Ansi*() functions. So I edited my answer, which was correct on older Delphi. Thanks for the feedback!
– Arnaud Bouchez
Nov 20 '18 at 11:08
SM_DBCSENABLED Nonzero if User32.dll supports DBCS; otherwise, 0. It is working, thank you @Arnaud. one question is will it work for 64 bit OS too or do we need to make changes?
– user10053091
Nov 20 '18 at 12:10
on my PC, it works on 64 bit too
– Arnaud Bouchez
Nov 20 '18 at 14:11
add a comment |
OS support double byte character but my question is about the language of OS is Japanese then its double byte character language and if language is English then it's not double byte character language. your answer gives me is user32.dll support double byte character or not. I debug with your ans. but value of SysLocale.FarEast is true in both cases of Japanese and English O.S.(operating system) which is because it's do support DBCS. @Arnaud
– user10053091
Nov 20 '18 at 10:12
you are right in newest Delphi there is: {$IF DEFINED(UNICODE)} SysLocale.FarEast := True; {$ELSE} SysLocale.FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0; {$ENDIF} Which IMHO is not correct, as used for Ansi*() functions. So I edited my answer, which was correct on older Delphi. Thanks for the feedback!
– Arnaud Bouchez
Nov 20 '18 at 11:08
SM_DBCSENABLED Nonzero if User32.dll supports DBCS; otherwise, 0. It is working, thank you @Arnaud. one question is will it work for 64 bit OS too or do we need to make changes?
– user10053091
Nov 20 '18 at 12:10
on my PC, it works on 64 bit too
– Arnaud Bouchez
Nov 20 '18 at 14:11
OS support double byte character but my question is about the language of OS is Japanese then its double byte character language and if language is English then it's not double byte character language. your answer gives me is user32.dll support double byte character or not. I debug with your ans. but value of SysLocale.FarEast is true in both cases of Japanese and English O.S.(operating system) which is because it's do support DBCS. @Arnaud
– user10053091
Nov 20 '18 at 10:12
OS support double byte character but my question is about the language of OS is Japanese then its double byte character language and if language is English then it's not double byte character language. your answer gives me is user32.dll support double byte character or not. I debug with your ans. but value of SysLocale.FarEast is true in both cases of Japanese and English O.S.(operating system) which is because it's do support DBCS. @Arnaud
– user10053091
Nov 20 '18 at 10:12
you are right in newest Delphi there is: {$IF DEFINED(UNICODE)} SysLocale.FarEast := True; {$ELSE} SysLocale.FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0; {$ENDIF} Which IMHO is not correct, as used for Ansi*() functions. So I edited my answer, which was correct on older Delphi. Thanks for the feedback!
– Arnaud Bouchez
Nov 20 '18 at 11:08
you are right in newest Delphi there is: {$IF DEFINED(UNICODE)} SysLocale.FarEast := True; {$ELSE} SysLocale.FarEast := GetSystemMetrics(SM_DBCSENABLED) <> 0; {$ENDIF} Which IMHO is not correct, as used for Ansi*() functions. So I edited my answer, which was correct on older Delphi. Thanks for the feedback!
– Arnaud Bouchez
Nov 20 '18 at 11:08
SM_DBCSENABLED Nonzero if User32.dll supports DBCS; otherwise, 0. It is working, thank you @Arnaud. one question is will it work for 64 bit OS too or do we need to make changes?
– user10053091
Nov 20 '18 at 12:10
SM_DBCSENABLED Nonzero if User32.dll supports DBCS; otherwise, 0. It is working, thank you @Arnaud. one question is will it work for 64 bit OS too or do we need to make changes?
– user10053091
Nov 20 '18 at 12:10
on my PC, it works on 64 bit too
– Arnaud Bouchez
Nov 20 '18 at 14:11
on my PC, it works on 64 bit too
– Arnaud Bouchez
Nov 20 '18 at 14:11
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388929%2fhow-to-get-language-of-operating-system-is-double-byte-in-delphi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
GetCPInfoEx(CP_ACP, 0, CpInfo);
NotSingleByte := CpInfo.MaxCharSize > 1
. OrTEncoding.GetEncoding(CP_ACP).IsSingleByte
. I think it depends on what you mean by language of operating system.– Sertac Akyuz
Nov 20 '18 at 10:59
It's unclear, what "double byte" means to you. Windows uses UTF-16 as its character encoding. Every code point is thus encoded in 2 or 4 bytes. It's also unclear why you need to know (whatever it is). What are you going to do with that information?
– IInspectable
Nov 20 '18 at 11:43