Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to match all double byte characters
#36
try this
Code:
Copy      Help
_s=
;class Program
;{
;,static void Main()
;,{
;,,//文件名 文字 中文
;,,Section section = new Section(document);
;,,document.Sections.Add(section);
;
;,,//This is the comment 中文
;,,Paragraph paragraph = new Paragraph(文件);
;,,section.Blocks.Add(paragraph);
;
;,,Run run = new Run(document, "文字");
;,,paragraph.Inlines.Add(run);
;
;,,document.Save("文件名.docx");
;,}
;}

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 342 200 "Dialog" "4"
;3 Edit 0x54030080 0x200 8 160 95 13 ""
;4 Edit 0x54030080 0x200 120 160 95 13 ""
;5 Edit 0x54030080 0x200 232 160 95 13 ""
;6 Edit 0x54231044 0x200 8 8 326 146 ""
;7 Button 0x54032000 0x0 96 180 110 14 "send modified content of E6"
;1 Button 0x54030001 0x4 216 180 48 14 "OK"
;2 Button 0x54030000 0x4 272 180 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040B01 "*" "" "" ""

str controls = "3 4 5 6"
str e3 e4 e5 e6
e6=_s
_s.replacerx("\s*//.*" "")
ARRAY(str) a
str pattern="[\x80-\xff]+" ;;Match all double byte characters
if(findrx(_s pattern 0 4 a)<0) out "does not match"; ret
for int'i 0 a.len
,sel i
,,case 0
,,e3 = a[0 i]
,,case 1
,,e4 = a[0 i]
,,case 2
,,e5 = a[0 i]

if(!ShowDialog(dd &sub.DlgProc &controls)) ret

ARRAY(int) linenumbers
ARRAY(str) b c
b=e6
for i 0 b.len
,if(findrx(b[i] "//.*")>=0)
,,linenumbers[]=i
for(i b.len-1 -1 -1) 
,for int'j 0 linenumbers.len
,,if(i=linenumbers[j])
,,,b.remove(i)
str s=b
int ci
for i 0 a.len
,sel i
,,case 0
,,ci=s.findreplace(a[0 i] F"{e3}" 4)
,,case 1
,,ci=s.findreplace(a[0 i] F"{e4}" 4 "" ci+e3.len)
,,case 2
,,ci=s.findreplace(a[0 i] F"{e5}" 4 "" ci+e4.len)
c=s
for i 0 c.len
,for j 0 linenumbers.len
,,if(i=linenumbers[j])
,,,str ss.getl(e6 linenumbers[j])
,,,c.insert(linenumbers[j])
,,,c[linenumbers[j]]=ss
_s=c
out _s.rtrim

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2

ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 7;;Original
,str Ori.getwintext(id(6 hDlg))
,DT_Cancel(hDlg)
,mes Ori
ret 1


Messages In This Thread
RE: Unable to match all double byte characters - by Kevin - 01-24-2021, 05:17 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)