注册 登录
编程论坛 VFP论坛

需要VFP9中显示国际音标如ŋ,但VFP9中读取包含Unicode字符的内容就乱码

shschy 发布于 2025-08-18 09:53, 1072 次点击
‌需要VFP9中显示国际音标如ŋ,但VFP9中读取包含Unicode字符的内容就乱码
搜索帮助,已改进到使用 Microsoft Form Text2.0控件来显示显示,
但是只能在控件上用键盘ctrl+v黏贴可以实现 国际音标(含Unicode字符的字符串),
一旦经vfp9内部操作,如“Microsoft Form Text2.0控件”.text=_cliptext,就乱码。

同时含unicode字符内容保存到dbf表(如insert into dbf 或 replace 某字段 with 某字符串),
也无法实现unicode字符正常保存与读取。

国际音标(IPA)符号的Unicode字符主要包括元音、辅音及特殊符号,
以下是部分常见字符的编码示例:
[ŋ]‌:后鼻音符号(U+014B) ‌
如‌:唱歌,sing‌,[siŋ]


60 回复
#52
shschy4 天前 09:10
采取  b=Thisform.AddObject("txtRich", "OleControl", "RICHTEXT.RichTEXTCtrl.1")
 可以通过 API 直接实现 b.textrtf =  FILETOSTR("!!音标.csv") 吗?
有现成的类似SetUEditText()API吗


#53
shschy4 天前 09:13
回复 38楼 sych -- SetWindowPos 只能实现对windows对象改位置宽高,请问对form类windows对象下的hUEdit子对象也可以直
请问 SetWindowPos 能对form类windows对象下的hUEdit子对象也可以直接修改位置宽高吗?

SetWindowPos可以实现,建议不要只是照抄代码,尝试着花点时间去理解大佬的代码是怎么实现的
我也是小白,仅当建议
#54
吹水佬4 天前 09:15
回复 51楼 shschy

用richtext控件就看看richtext的相关参考资料。

#55
吹水佬4 天前 09:17
关键不是SetUEditText(),SetUEditText只是读取文件。
关键是控件如何显示输出数据。
#56
sych4 天前 09:27
回复 53楼 shschy
你是说的太多,做的太少
DEFINE CLASS formUEdit as Form
    ShowWindow = 2
    hUEdit     = 0
    PROCEDURE Activate
        this.hUEdit = CreateUEdit(this.hWnd)
        SetFont(this.hUEdit, 24, "Arial")
        SetFocus(this.hUEdit)
        SetUEditText(this.hUEdit, STRCONV(0h7369C58B00,12))
DECLARE INTEGER SetWindowPos IN Win32API ;
INTEGER hWnd, INTEGER InsertAfter, ;
INTEGER left, INTEGER top, ;
INTEGER width, INTEGER height, ;
INTEGER flags
SetWindowPos ( this.hUEdit,0 , ;
0, 0, ;
300, 200, ;
16)
    ENDPROC
    PROCEDURE Destroy
        DestroyUEdit(this.hUEdit)
        CLEAR EVENTS
    ENDPROC
ENDDEFINE

#57
shschy4 天前 11:16
感谢提醒,查到SetWindowPos()是 Win32API 里已有的。回复 56楼 sych
感谢提醒,查到SetWindowPos()是 Win32API 里已有的。回复 56楼 sych
DEFINE CLASS newformUEdit as Form
    width      = 420
    height     = 700   
    ShowWindow = 2
    hUEdit     = 0
    PROCEDURE Activate
        this.hUEdit = CreateUEdit(0,0,400,700,this.hWnd)
        SetFont(this.hUEdit, 24, "Arial")
        SetFocus(this.hUEdit)
        SetUEditText(this.hUEdit, FILETOSTR("!!音标.csv"))
        DECLARE INTEGER SetWindowPos IN Win32API ;
        INTEGER hWnd, INTEGER InsertAfter, ;
        INTEGER left, INTEGER top, ;
        INTEGER width, INTEGER height, ;
        INTEGER flags
        SetWindowPos ( this.hUEdit,  0 , 0, 0, 250, 600, 16)
      &&SetWindowPos (hWnd,hWndInsertAfter,         HWND,int X          ,          int Y,  int cx,  int cy,uFlags  )
      &&SetWindowPos (目标窗口句柄,Z轴顺序的相对窗口句柄,窗口左上角X坐标,窗口左上角Y坐标,窗口宽度,窗口高度,操作标志)
    ENDPROC
    PROCEDURE Destroy
    ENDPROC
ENDDEFINE
#58
sych4 天前 11:18
使用richtext控件
fname="11.txt"  &&注意这个文件是UTF-8格式的
SYS(3101,65001)
WITH thisform.Olecontrol5
    .loadFile(fname,1)
    .SelStart = 0
    .SelLength = LEN(.Text)
    .SelColor = RGB(0, 0, 255)
    .SelFontName = "黑体"
    .SelFontSize = 16
ENDWITH
SYS(3101,0)
retu
只有本站会员才能查看附件,请 登录
#59
shschy4 天前 11:39
SetWindowPos ()在do *.PRG中可以起作用,在command.click中能起作用吗,下面click中SetWindowPos无效
command1.click 代码如下

PUBLIC txtRich_test
txtRich_test=Thisform.AddObject("txtRich", "OleControl", "RICHTEXT.RichTEXTCtrl.1")

?txtRich_test
Thisform.txtRich.visible=.t.
Thisform.txtRich.width=300
Thisform.txtRich.height=600
Thisform.txtrich.textrtf=FILETOSTR("!!音标.csv")

MESSAGEBOX("点确定后,新建txtRich类控件 尺寸改变",0,"")

SetWindowPos (txtRich_test,  0 , 0, 0, 50, 500, 16)

command1.click 代码如上
以下是引用sych在2025-8-22 09:27:25的发言:

你是说的太多,做的太少
DEFINE CLASS formUEdit as Form
    ShowWindow = 2
    hUEdit     = 0
    PROCEDURE Activate
        this.hUEdit = CreateUEdit(this.hWnd)
        SetFont(this.hUEdit, 24, "Arial")
        SetFocus(this.hUEdit)
        SetUEditText(this.hUEdit, STRCONV(0h7369C58B00,12))
DECLARE INTEGER SetWindowPos IN Win32API ;
INTEGER hWnd, INTEGER InsertAfter, ;
INTEGER left, INTEGER top, ;
INTEGER width, INTEGER height, ;
INTEGER flags
SetWindowPos ( this.hUEdit,0 , ;
0, 0, ;
300, 200, ;
16)
    ENDPROC
    PROCEDURE Destroy
        DestroyUEdit(this.hUEdit)
        CLEAR EVENTS
    ENDPROC
ENDDEFINE

#60
shschy4 天前 12:07
谢谢 58楼 sych!但这里测试不成功,基本显示也没有,loadfile()报错,特地加了file()判断,证明文件确实存在
fname="音标UTF-8.txt"  &&注意这个文件是UTF-8格式的
IF FILE("音标UTF-8.txt")
   SYS(3101,65001)
   WITH thisform.Olecontrol5
        .loadFile("音标UTF-8.txt",1)此句报错
        .SelStart = 0
        **.SelLength = LEN(.Text)
        .SelColor = RGB(0, 0, 255)
        .SelFontName = "黑体"
        .SelFontSize = 16
   ENDWITH
   SYS(3101,0)
ENDIF
只有本站会员才能查看附件,请 登录
#61
hsfisher昨天 08:25
学习了
12