printfn not producing expected results for international (non-latin) characters - f#

I have the following program:
let txt = "إتصالات"
printfn "Text is: %s" txt
0 // return an integer exit code
The value of txt is being set to some Arabic characters. When I run the program what is being displayed on the console is a bunch of question marks rather than the characters. In the Visual Studio 2012 debugger the correct characters are being displayed for the txt variable.
What am I doing wrong and how does one properly display international characters?

According to How to write unicode chars to console? you need to set the OutputEncoding property on the console, like this:
System.Console.OutputEncoding <- System.Text.Encoding.Unicode
let txt = "إتصالات"
printfn "Text is: %s" txt
0 // return an integer exit code
The answer for that question is worth reading though, because it also describes why you need to change your console font to really make this work, and also how to do it.
Here are some additional links with more information:
Necessary criteria for fonts to be available in a command window (this is for Windows 2000 and may not entirely apply to Windows 8, but it should give you a good idea of what to look for in a font).
Windows Console and TrueType Fonts shows how to add new fonts to the console.
Anyone who says the console can't do Unicode isn't as smart as they think they are has some background information about writing Unicode text to the console.
Update: Since the Arabic text in the example renders just fine here on StackOverflow, I peeked at the CSS to see which fonts they're using to render preformatted text. Using that list and the Windows Character Map tool (Start -> All Programs -> Accessories -> System Tools -> Character Map), I've found the Courier New font (which ships with Windows) supports Arabic characters. If you use the registry hack in the "Windows Console and TrueType Fonts" link (above), you should be able to add Courier New as a font you can use in the console.

Related

jsPDF doesn't show certain letters properly (ū)

I am trying to create a PDF File to export using jsPDF library. In one of the lines I am trying to write a word that contains this 'ū' letter,
doc.text('Hūla', 20, 30);
However, when doing so the exported file doesn't contain this letter but instead it becomes
'H k l a' with spaces in between and a k instead of the ū.
What can I do in order to have this printed properly?
The solution was to use a font that supports this. I had to try multiple ones in order to get it working with this letter ū (it is not a specific language)
The font was Amiri. It also supported the Arabic font.

ZPL command barcode 3 zeros creates issues

I am trying to print to a GT800 Zebra printer thru serial port.
I am using ZPL. I want to control the width which is fine in auto mode. To address that in the >^BC> command I am using Auto mode as no other size setting under ^BY works
Following is the code
^XA
^MMT
^PW831
^LL400
^LS0
^BY2,,76^FT225,141^BCN,76,Y,Y,N,A
^FD:RNIP29200082034^FS
^FO225,157^A#N,18,10,E:CAL002.FNT^FD26030-0892R^FS
^FO383,157^A#N,18,10,E:CAL002.FNT^FD08.01.20 12:00PM^FS
^FO225,187^A#N,18,10,E:CAL002.FNT^FDLAMP-DR RH^FS
^FO453,187^A#N,18,10,E:CAL002.FNT^FDXBA3^FS
^PQ1,0,0,Y
^XZ
There is a funny problem. If the ^BC mode = A then if three zeros come together gives issues for eg ABCD29200082034 it prints ABCD29200 and does not complete the barcode. But the other lines are getting printed. But if the data is ABCD29200182034 , there are no issues.
If BC mode = U then even if the code is ABCD29200182034 it prints 292001820347. Note 7 is added in the end.
I am clueless as to what is this issue. I remember facing this same issue in Honeywell printer too once.
Thanks
NOTE : I replaced the 000 with 111 and the problem persists.
ZPL Manual says the following
A= Automatic Mode :This analyzes the data sent and automatically determines the best packing method. The full ASCII character set can be used in the ^FD
statement — the printer determines when to shift subsets. A string of
four or more numeric digits causes an automatic shift to Subset C.
Note , it says a string of four or more numeric digits causes an automatic shift to subset C, but when the same string is 290010 it has no issues. I am really lost

Pipe character ignored in SPSS syntax

I am trying to use the pipe character "|" in SPSS syntax with strange results:
In the syntax it appears like this:
But when I copy this line from the syntax window to here, this is what I get:
SELECT IF(SEX = 1 SEX = 2).
The pipe just disappears!
If I run this line, this is the output:
SELECT IF(SEX = 1 SEX = 2).
Error # 4007 in column 20. Text: SEX
The expression is incomplete. Check for missing operands, invalid operators,
unmatched parentheses or excessive string length.
Execution of this command stops.
So the pipe is invisible to the program too!
When I save this syntax and reopen it, the pipe is gone...
The only way I found to get SPSS to work with the pipe is when I edited the syntax (adding the pipe) and saved it in an alternative editor (notepad++ in this case). Now, without opening the syntax, I ran it from another syntax using insert command, and it worked.
EDIT: some background info:
I have spss version 23 (+service pack 3) 64 bit.
The same things happens if I use my locale (encoding: windows-1255) or Unicode (Encoding: UTF-8). Suspecting my Hebrew keyboard I tried copying syntax from the web with same results.
Can anyone shed any light on this subject?
Turns out (according to SPSS support) that's a version specific (ver. 21) bug and was fixed in later versions.

How do you define the length of a parameter in ESC/POS?

I need to be able to print Hebrew characters on my Epson TM-T20ii. I am trying to get my printer to switch to character code page 36(PC862) using
ESC t36
for some reason the printer is switching to code page 3 and then printing the number 6.
Is there a way to let the printer know that the 6 is part of my command?
If you know of a different workaround please comment below.
Thanks
You are making a mistake, you aren't meant to replace n with an actual number.
The proper syntax in your case would be ←t$
Explanation: the manual says "ESC t n", n referring to the page sheet, however you don't replace n with a number rather with the ASCII character n, so in your example 36 = $ because $ is the 36th character on the ASCII table.

Parse a Word Document By Font?

I'm currently trying to write a script which would run through a word document and output to a text file all the lines that are written in a certain font.
So if I had the document:
"This is the first line of the document.
This is the second line of the document.
This is the third line of the document."
And say normal lines are Times New Roman, bold is Arial, and italics is Sans Serif.
Then, ideally, I could parse the document for all lines in Arial and the text file output would have the line:
This is the second line of the document.
Any idea on how to do this from a script? I was thinking about first converting the doc into xml, but I do not think this is possible within a script.
You'll want to use the FIND object, and the FONT property of the FIND object.
So, something like this:
Public Sub FindTest()
Dim r As Range
Set r = ActiveDocument.Content
With r.Find
.ClearFormatting
.Style = "SomeStyleName"
Do While .Execute(Forward:=True, Format:=True) = True
'---- we found a range
Dim duperange As Range
Set duperange = r.Duplicate
Debug.Print r.Text
Loop
End With
End Sub
Note that where I've specified Style, you could specify font formatting via the FIND.FONT object, or various other formatting options. Just browse around the FIND object to see what's available.

Resources