What is &H14& in VBScript? - vbscript

I found the following article : here about installing fonts on a Windows computer via a script. The author uses VBScript to do that, but I'd like to use Ruby/Python. There is a line in the script I don't understand :
Const FONTS = &H14&
What is that &H14&? Is it a number? How would I represent that in another language?

The &H prefix is used to write a number in hexadecimal. The hexadecimal number 14 is the decimal number 20.
The & suffix means that the number is of the type Long (32 bit integer).
So, &H14& is a numeric literal of the type Long with the value 20.

It's a number in hexadecimal. &H14& can be written in some programming languages as 0x14.
The value is used to represent the special folder "Fonts" .. more info

Related

When using a convert char to ASCII value routine, need to find out what values it is actually returning as they are not strictly ascii

When testing my code that uses a routine that checks for chars to show using an ASCII value routine, my program should drop control chars but keep chars that may be entered by the user. It seems that while the ASCII value routine is called "ascii", it does not just return ascii values: giving it a char of ƒ returns 402.
For example have found this web site
but it doesn't have ƒ 402 that I can see.
Need to know whether there are other ascii codes above 402 that I need to test my code with. The character set used internally by the software that 'ascii' is written in uses UCS2. The web site found doesn't mention USC2.
There are probably many interpretations ouf »Control Character« out there, but I'll assume you mean C0 and C1 control characters (includes references to the relevant Unicode Standards).
The commonly used 32-bit integer representation of Unicode characters in general is the codepoint notation: »U+« followed by a at least 4 digit positive hex number, which you will find near mentions of characters, e.g. as in »U+007F (delete)«. The result of your »ASCII value« routine will probably be this number without the »U+«;
UCS-2 is a specific encoding for Unicode characters, which you probably won't need to care about directly), and is equivalent to Unicode codepoints for all characters within the the range of the BMP only.

DirectWrite ScriptAnalysis get script name from index

DirectWrite ScriptAnalysis Contains a UINT16 number that is zero-based index representation of writing system script.
How can I know the name of the script?
For example in English the number is equal to 49, and in Russian the number is equal to 22.
Is there a table of all languages somewhere?
You can use IDWriteTextAnalyzer1::GetScriptProperties(), it will return script info for given script analysis result. If you need a display name instead of script ISO codes, you'll need your own mapping table.
By using IDWriteTextAnalyzer1::GetScriptProperties() you'll get ISO codes.
The table of languages can be found on the Unicode.org site.
It is called "Codes for the representation of names of scripts"
Here is the link for that:
http://unicode.org/iso15924/iso15924-codes.html

Windows CE / UTF-16 / Chinese

I've read that Windows CE uses the "UTF-16 version of UNICODE" (i'm a newbie with encodings).
What happens when a string contains a character that requires more that 2 bytes, like chinese characters ? Does it take 3 ?
If i have a string containing chinese characters, accessing the N-th couple of bytes will not necessaily access the N-th visible symbol ?
Also what about performance ? If i understand well, encodings that have a variable number of bytes per visible symbol require the string to be scanned from the beginning to access the N-th visible symbol right ? If yes is it also true for UTF-16 ?
Thank you.
What happens when a string contains a character that requires more that 2 bytes, like Chinese characters? Does it take 3?
No, four.
Wikipedia: UTF-16:
In UTF-16, code points greater or equal to 216 are encoded using two 16-bit code units.
If I understand well, encodings that have a variable number of bytes per visible symbol require the string to be scanned from the beginning to access the N-th visible symbol right?
Yes. See for example Why use multibyte string functions in PHP?.

Change integer into hex Ruby

I am currently porting a perl project to ruby and all has been going fine until I reached this pack statement.
$move .= pack('W', int($length));
I understand what it's trying to do, but I can't find any documentation on the 'W' option for perls pack method. So it is a bit hard to find a suitable replacement for ruby.
What this statement does is takes the integer, and converts it to a big endian hex format (I believe).
For example the integer 290 is converted to 0x122, and is then stored as "2201" in the variable $move
Although I cannot confirm that because I can't find documentation on 'W' although it would make sense based on what the rest of the project is doing.
Does anyone know a ruby replacement method that would do the same?
edit: As per a comment below I have found it with some help.
W An unsigned char value (can be greater than 255).
Since the format's introduction in 5.10, pack says:
W An unsigned char value (can be greater than 255).
For example, the following are equivalent:
pack('W', 0x2660)
chr(0x2660)
"\x{2660}"
For all values of $i, length(pack('W', $i)) is one.
What's the size of a character (string element) in Ruby? Are they 8 bits like C, or larger like Java (16) and Perl (32 or 64)?
If they are limited to 8 bits, there is no direct equivalent of that code in Ruby. You'll need to use an array instead of a string.
If Ruby's character are wide enough to contain the numbers in question (e.g. 290), then a look through the Ruby docs reveals the following:
i.chr

Visual basic handle decimal comma

I'm trying to save variables into text files and the Czech typographic rules drives me crazy.
The program I'm tuning is dedicated to work on Czech localized computers where decimal comma is used but the VB is working with normal, standard decimal dot.
When loading files "US" decimals are loaded correctly and showed as Czech decimals. In TextBoxes "Czech" decimals are required. My problem is that program generates Czech decimals and require the "US" ones.
How can I force VB program to read comma as decimal sign instead of delimiter or how to export data with dots instead of commas?
Yes I can load 123,456 as a=123 and b=456 and then return value as a + b/1000 but is there more elegant solution?
Pick the right function.
Val, Str will always use US settings (dot as decimal)
CDbl, Format will take account of the regional settings.
It's all in the manual section on international programming.
Your trouble might be due to use of the Val function; that isn't international. The help text recommends the use of CDbl when converting from strings to numbers.
Thanks for your advices, I'm not sure if I did something wrong, but I've obtained only errors (ie. type mismatch) or "Czech" decimal comma.
I've tried 'Got slapped? Slap him harder!' aproach with this code:
Dim PpP As String, SaveFile As Integer
PpP = Form1.TxtA10.Text & " " & Form1.TxtA11.Text
PpP = Replace(PpP, ",", ".")
Print #SaveFile, PpP
edit:
something means trying those functions at the output, not at the input. (like trying Double as String parameter).
This code:
Input #1,TempString
Form1.TxtA10.Text = CDbl(TempString)
works aswell.
Try,
Format$(CDbl(Text1.Text), "#,##0.00")

Resources