亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

報錯 :invalid byte sequence in UTF-8 (ArgumentError)

報錯 :invalid byte sequence in UTF-8 (ArgumentError)

森林海 2023-03-15 21:17:26
#encoding: UTF-8require "win32ole"require "Win32API" FindWindowEx = Win32API.new("user32", "FindWindowExA", ["l", "l", "p", "p"], "l") GetWindowText = Win32API.new("user32", "GetWindowTextA", ["L","P","i"], 'i') GetClassName = Win32API.new("user32", "GetClassName", ["L","P","i"], "l") GetWindowTextLength = Win32API.new("user32", "GetWindowTextLength", "L", "I")# GetWindowText 獲取窗口標題 URL_handle = FindWindowEx.call(0, 0, "DV2ControlHost", nil) buf_len = GetWindowTextLength.call(URL_handle) str_a = " " * (buf_len + 1) GetWindowText.call(URL_handle, str_a, str_a.length) puts str_a.delete("\0")執行后報錯:in `delete': invalid byte sequence in UTF-8 (ArgumentError)Class Name: "DV2ControlHost"Window Caption: "「開始」菜單"
查看完整描述

1 回答

?
繁星點點滴滴

TA貢獻1803條經驗 獲得超3個贊

使用delete(“\0”) 前 ,先處理下編碼 用force_encoding("iso-8859-1")
,或者再試下其他編碼格式。
祝你好運。

查看完整回答
反對 回復 2023-03-18
  • 1 回答
  • 0 關注
  • 111 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號