Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extended ASCII Codes, QM output incorrect
#1
How do I output _s correctly in below example?
ss contains Extended ASCII Code (see https://www.asciitable.com)

I looked in settings and QM is running in unicode.

Macro Macro29
 
Code:
Copy      Help
str ss="▓▓" ;; https://www.asciitable.com/ -> 2 x 178
out ss ;; correct output
_s.left(ss 1)
;; _s.ConvertEncoding(? ?)  --->   65001    utf-8    Unicode (UTF-8)   <---- https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers edit: _unicode is same as 65001
out _s ;; incorrect output
#2
_s.left(ss 1) makes _s invalid. Now it contains part of a 3-byte UTF-8 character.

Maybe you want to use ss.ConvertEncoding, but I don't know which encoding contains character ▓.
#3
Ok Thanks!
#4
The character comes from copdepage 437, IBM437
https://en.wikipedia.org/wiki/Code_page_437 -> [ALT]+[178]  (scroll down on that wiki page and you see table)
#5
QM
Code:
Copy      Help
str ss="▓▓"
_s.left(ss 3)
out _s
_s.ConvertEncoding(-1 437)
out _s ;;xB2
out _s[0] ;;178

LA/C#
Code:
Copy      Help
var ss = "▓▓";
var _s = ss[..1];
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var a = Encoding.GetEncoding(437).GetBytes(_s);
print.it(a, (int)a[0]);
#6
This works thank you!


Forum Jump:


Users browsing this thread: 1 Guest(s)