英文:
How to check Korean language? - PROGRESS 4GL
问题
以下查询帮助我查找中文字符,但如何查找韩文字符?
英文:
Below query is helping me to find out Chinese characters but how can we find Korean characters?
Procedure check_chinese :
Define input parameter m_char as Character no-undo.
define output parameter m_error as logical no-undo.
Define variable m_ret as Character no-undo.
Define variable i as Integer no-undo.
do i = 1 to length(m_char,"raw"):
if ( (asc(substring(m_char,i,1,"raw")) >= 97 and
asc(substring(m_char,i,1,"raw")) <= 122) )
or ((asc(substring(m_char,i,1,"raw")) >= 65 and
asc(substring(m_char,i,1,"raw")) <= 90))
and (asc(substring(m_char,i,1,"raw")) <> 32 )
then
do:
m_error = yes.
leave.
end.
答案1
得分: 1
假设您的会话内部代码页是 utf-8,您可以在 longchar 变量上修复代码页,将输入复制到该变量并在分配时捕获错误。我还假设 CP949 是适用于韩文的代码页。
function isKorean returns logical (
i_lc as longchar
):
def var lresult as logical no-undo initial true.
def var lc as longchar no-undo.
fix-codepage( lc ) = 'CP949'.
do on error undo, throw:
copy-lob from i_lc to lc.
catch e as progress.lang.error:
if e:getMessageNum(1) = 11395 then
lresult = false.
else
undo, throw e.
end catch.
end.
return lresult.
end function.
message
'说説' '~t' isKorean( '说説' ) skip
'한국어 ' '~t' isKorean( '한국어 키보드' )
view-as alert-box.
英文:
Assuming that your session internal code page is utf-8, you can fix the codepage on a longchar variable, copy your input to it and trap an error when assigning. I am also assuming that CP949 is a suitable codepage for Korean.
function isKorean returns logical (
i_lc as longchar
):
def var lresult as logical no-undo initial true.
def var lc as longchar no-undo.
fix-codepage( lc ) = 'CP949'.
do on error undo, throw:
copy-lob from i_lc to lc.
catch e as progress.lang.error:
if e:getMessageNum(1) = 11395 then
lresult = false.
else
undo, throw e.
end catch.
end.
return lresult.
end function.
message
'说説' '~t' isKorean( '说説' ) skip
'한국어 ' '~t' isKorean( '한국어 키보드' )
view-as alert-box.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论