How to specify comma , space unicode value in app.config(C#3.0) - c#-3.0

In the app.config file if I use
<add key = "FileDelimeter" value ="&#2c;"/> as unicode for COMMA, it is throwing error
Invalid character in a decimal number 'c'
For SPACE, <add key = "FileDelimeter" value =""/> the error is
Character'', hex value 0*14 is illegal
in xml
while <add key = "FileDelimeter" value =" "/> for "\t" worked.
Where is the mistake?
Kindly give a generic solution.
Thanks

The &# prefix denotes a decimal (base 10) number. Try using &#x (the 'x' is for Hexadecimal) as the prefix:
<add key = "FileDelimeter" value =","/>

Related

Commas in SUMMARY icalendar

Is it ok to have commas in a summary tag in a ics document?
Because I am using calcurse to load an .ics and it doesn't load the event with summary comma separated.
According to the RFC5545 Specification, Comma's need to be backslashed in that situation. See:
SUMMARY is defined here: https://www.rfc-editor.org/rfc/rfc5545#section-3.8.1.12 as of Value Type: TEXT
TEXT is defined here: https://www.rfc-editor.org/rfc/rfc5545#section-3.3.11
Here is part of the above specification that describes what to do with certain characters if you want to include them in a text value:
text = *(TSAFE-CHAR / ":" / DQUOTE / ESCAPED-CHAR)
; Folded according to description above
ESCAPED-CHAR = ("\\" / "\;" / "\," / "\N" / "\n")
; \\ encodes \, \N or \n encodes newline
; \; encodes ;, \, encodes ,
TSAFE-CHAR = WSP / %x21 / %x23-2B / %x2D-39 / %x3C-5B /
%x5D-7E / NON-US-ASCII
; Any character except CONTROLs not needed by the current
; character set, DQUOTE, ";", ":", "\", ","
Description: If the property permits, multiple TEXT values are
specified by a COMMA-separated list of values.
...
The "TEXT" property values may also contain special characters
that are used to signify delimiters, such as a COMMA character for
lists of values or a SEMICOLON character for structured values.
In order to support the inclusion of these special characters in
"TEXT" property values, they MUST be escaped with a BACKSLASH
character. .... A COMMA character in
a "TEXT" property value MUST be escaped with a BACKSLASH
character. ....

Lex Parsing for exponent

I am trying to parse a file the data looks like
size = [5e+09, 5e+09, 5e+09]
I have 'size OSQUARE NUMBER COMMA NUMBER COMMA NUMBER ESQUARE'
And NUMBER is defined in tokrules as
t_NUMBER = r'[-]?[0-9]*[\.]*[0-9]+([eE]-?[0-9]+)*'
But I get
Syntax error in input!
LexToken(ID,'e',6,113)
Illegal character '+'
Illegal character '+'
Illegal character '+'
What is wrong with my NUMBER definition?
I am using https://www.dabeaz.com/ply/
The part of your rule which matches exponents is
([eE]-?[0-9]+)*
Clearly, that won't match a +. It should be:
([eE][-+]?[0-9]+)*
Also, it will match 0 or more exponents, which is not correct. It should match 0 or 1:
([eE][-+]?[0-9]+)?

Why is Swift Decimal Returning Number from String Containing Letters?

I am working with Swift's Decimal type, trying to ensure that an user-entered String is a valid Decimal.
I have two String values, each including a letter, within my Playground file. One of the values contains a letter at the start, while the other contains a letter at the end. I initialize a Decimal using each value, and only one Decimal initialization fails; the Decimal initialized with the value that contains the letter at the beginning.
Why does the Decimal initialized with a value that contains a letter at the end return a valid Decimal? I expect nil to be returned.
Attached is a screenshot from my Playground file.
It works this way because Decimal accepts any number values before the letters. The letters act as a terminator for any numbers that comes after it. So in your example:
12a = 12 ( a is the terminator in position 3 )
a12 = nil ( a is the terminator in position 1 )
If wanting both to be invalid if the string contains a letter then you could use Float instead.

emoji cannot be a literal and what else?

A literal is the source code representation of a value of a type, such as a number or string
There are 3 kinds of literals in Swift: Integer Literals, Floating-Point Literals and String Literals (please correct me if I'm wrong), Is that means (My Guess) any elements which not belong to a type of Integer, Floating or String is not considered as a literal, and will trigger an error when used as literals
According to what I guess I've tried this let aEmoji = 😀
Question1: Is my guess accurate? If not, I appreciate you could correct me.
Question2: Is there anything else shouldn't use as a literal? (would be nice you could give me some example)
Thanks
A string literal is wrapped in double quotes
let aEmoji = "😀"
From the documentation:
A string literal is a fixed sequence of textual characters
surrounded by a pair of double quotes ("").
Yes, anything that isn't an integer literal (1), floating-point literal (1.0) or String literal ("foo"), Array literal ([foo]), Dictionary literal ([foo : bar]), bool literal (true/false) isn't a literal and would cause an error.
Anything that isn't one of the literals above isn't a literal, and could cause an error (if it's an invalid syntax).
You can make put an emoji in a string literal, however: let aEmoji = "😀"
You can include emojis in a literal String or Character expression by setting it off with double quotes.
The type inferrer will default the expression to a String literal, unless the Character type is specified.
let unicornString = "🦄"
let unicornChar : Character = "🦄"
Else the compiler will treat the emoji (or any unicode character sequence) as an identifier (because emoji can be variable names and such).
The following would be valid:
let 🔑 = "myPassword"
user.authenticateWithPassword(🔑)

String to Integer (atoi) [Leetcode] gave wrong answer?

String to Integer (atoi)
This problem is implement atoi to convert a string to an integer.
When test input = " +0 123"
My code return = 123
But why expected answer = 0?
======================
And if test input = " +0123"
My code return = 123
Now expected answer = 123
So is that answer wrong?
I think this is expected result as it said
Requirements for atoi:
The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value.
Your first test case has a space in between two different digit groups, and atoi only consider the first group which is '0' and convert into integer