How do lower case letters works in QR code? - character

I have a little doubt about QR character list. A summary of the specification is here:
Numeric only Max. 7,089 characters (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
Alphanumeric Max. 4,296 characters (0–9, A–Z [upper-case only], space, $, %, *, +, -, ., /, :)
Binary/byte Max. 2,953 characters (8-bit bytes) (23624 bits)
Kanji/Kana Max. 1,817 characters
How does it works for the characters out side these lists, like lower case letters or ~,? etc.?
As for example : The QR code for a~?bC generated from here:
enter image description here
How does it work? Because few characters ~ ? a b are not listed in the standard QR code character list.

It would appear that they would just occupy more data/blocks per character and increase qr size to higher level, becoming less space efficient.

Related

Efficiently encoding a bit array into a limited alphabet

This is an efficient encoding problem.
The input is a variable length bit array with a maximum length of 63. For example:
[0, 0, 0, 1, 0, 0, 1]
0s are much more common in this array than 1s. Lets say 1s are found about 5% of the time.
My output format is also constrained. I can output a string consisting only of the 36 characters a-z and 0-9. Variable length output is fine.
I want a lossless encoding algorithm that minimizes my average output string length.
A simple lossless encoding would be to assign each of the first 32 letters in my output alphabet to a unique 5 bit sequence, split my input into 5-bit outputs, and output one letter per 5 bits. This gives me an expected string length of: input array size / 5.
However, this does not exploit either the low probability of 0s in the input, nor the remaining 4 letters in my alphabet.
Can you suggest a better encoding scheme?

Hi everyone. I am struggling with converting binary to decimal as an 8 bits number

I have a question.
How do I convert 100000000(as a 8 bit number) to decimal . Thanks for helping
The example given has nine bits, not eight: a "1" and eight "0"s.
First you must know what form of binary number it is, as there are several conventions, such as unsigned, signed, binary coded decimal, etc.
Assuming that this is a simple, unsigned binary number, the nine bits have the following values: 256, 128, 64, 32, 16, 8, 4, 2, and 1. To find the value in decimal, add up all the values that have a "1" in that position. In this case, the number in decimal is simply 256.
Another example might be: 010001001 In this case, you add 128, 8, and 1, to get 137. This can also be represented by an eight-bit number: 10001001
If, on the other hand, this is a signed number, it's more complicated. For a signed nine-bit number (which is not often encountered), the ninth bit on the left says whether it's negative or positive, with a "1" indicating negative. In the "twos complement" form, the remaining bits are inverted and then 1 is added. In this case, 00000000 is inverted to 11111111, then 1 is added, making it 100000000, or 256. Thus the number is -256.

How to fix extra space that MATLAB displays after first iteration

I have an fprintf statement which loops 3 times in order to display some data. After the first iteration, MATLAB displays a mysterious space even though I have not added an extra \t. It acts as if I had an if statement to display a different fprintf statement after the first iteration, but I have nothing like that on the code. See picture on the link for the result it displays
% Display results
fprintf('Panel\tPressure Cl\tCd\t| Panel\tPressure Cl\tCd\n')
for q = 1:length(AOA)
fprintf('--------------\t-------\t------- |--------------\t--
-----\t-------\n')
fprintf('AOA %.0f°\t\t%.4f\t%.4f\t|AOA %.0f°
\t\t%.4f\t%.4f\n'...
,AOA(q),Cl(q),CD(q),AOA(q),ClFinal(q),CDFinal(q))
fprintf('--------------\t-------\t------- |--------------\t--
-----\t-------\n')
for j = 1:length(pressure{1})
fprintf('%.0f\t%.4f\t |\t |\t|%.0f\t%.4f\n',j+1,pressure{q}
(j),j+1,pFinal{q}(j))
end
end
When you fprintf a \t character, there is an automatic space padding up to 4 spaces. If the string has less than 4 characters, the string will be placed at the start and be "space padded" until 4 characters have been filled (in reality, the space padded characters resemble just one character). If the string has more than 4 characters, then it will space pad at 8, 12, 16, etc...
Here is what your question is really about:
fprintf('Panel\tPressure Cl\tCd\t| Panel\tPressure Cl\tCd\n')
The first string Panel has 5 characters, and therefore will be space padded with the equivalent of 3 spaces at the end of the first Panel. However, the second string | Panel has 7 characters, and therefore will only need the equivalent of 1 space at the end of the second string.
To remove your spacing issue, and have a more uniform spacing between your text headers, you can place a tab character after every header you want, and change your formating for your other fprintf statements accordingly:
fprintf('Panel\tPressure\tCl\t\tCd\t\t|\tPanel\tPressure\tCl\t\tCd\n')
You can also view this link for another example of how space padding works.
Also, here is the MATLAB Documentation on Formatting Text.

Recognizing Unicode numbers from different languages

In Unicode every language will have their own number. For example ASCII has "3", Japanese has "3", and so on. How can I identify a three no matter what unicode byte it is represented by?
Read about normative properties Decimal digit value, Digit value and Numeric value in UnicodeData File Format:
Decimal digit value normative This is a numeric field. If the character has the decimal digit property, as specified in Chapter 4 of
the Unicode Standard, the value of that digit is represented with an
integer value in this field.
Digit value normative This is a numeric field. If the character represents a digit, not necessarily a decimal digit, the
value is here. This covers digits which do not form decimal radix
forms, such as the compatibility superscript digits.
Numeric value normative This is a numeric field. If the character has the numeric property, as specified in Chapter 4 of the
Unicode Standard, the value of that character is represented with an
integer or rational number in this field. This includes fractions as,
e.g., "1/5" for U+2155 VULGAR FRACTION ONE FIFTH Also included are
numerical values for compatibility characters such as circled numbers.
For instance, Python's unicodedata module provides access to the Unicode Character Database which defines character properties for all Unicode characters, see implementation: unicodedata — Unicode Database:
import unicodedata
numchars = '\u0033','\u00B3','\u0663','\u06F3','\u07C3','\u0969','\uFF13','\u2155'
for numchar in numchars:
print( numchar
, unicodedata.decimal( numchar, -1)
, unicodedata .digit( numchar, -1)
, unicodedata.numeric( numchar, -1)
, unicodedata .name( numchar, '? ? ?') )
Output:
==> D:\test\Python\Py3\41045800.py
3 3 3 3.0 DIGIT THREE
³ -1 3 3.0 SUPERSCRIPT THREE
٣ 3 3 3.0 ARABIC-INDIC DIGIT THREE
۳ 3 3 3.0 EXTENDED ARABIC-INDIC DIGIT THREE
߃ 3 3 3.0 NKO DIGIT THREE
३ 3 3 3.0 DEVANAGARI DIGIT THREE
3 3 3 3.0 FULLWIDTH DIGIT THREE
⅕ -1 -1 0.2 VULGAR FRACTION ONE FIFTH
==>
P.S. Given Python example as the question is not tagged to any particular language.

How do I set the fill character for displaying numbers (Objective C)

I'm trying to format a string to give me 2 characters for a number, no matter what its value. Right now, I have
[NSString stringWithFormat:#"%2d:%2d:%2d",h,m,s)];
and for the values 1, 2, 3, the output is
1: 2: 3
How do I change the spaces to 0's ?
This is done the same as C's printf (see man 3 printf):
[NSString stringWithFormat:#"%02d:%02d:%02d",h,m,s];
(By the way, if you're trying to format dates or times, I'd suggest looking at NSDateFormatter.)