Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How can I get a string or array consisting of all the diacritics for a given character in swift?
Thanks,
Michael
The Unicode standard defines 112 common diacritical marks, each of them can combine with every character a - z (and their uppercase):
let characters = Array("abcdefghijklmnopqrstuvwxyz".characters)
for char in characters {
for i in 0x0300...0x036F {
let diacritic = UnicodeScalar(i)
var str = String(char)
str.append(diacritic)
print(str, terminator: " ")
}
print()
}
What you see on the iPhone keyboard is a select number of diacritic marks that Apple has chosen for each character, possibly based on the keyboard's language. You would have to do the same if you don't want to overwhelm your users with choice.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I need to replace certain letters in a word with a character.
I'm stuck. How can I fix it?
It looks like you already have most of the code. You just need to add the letters that don't need to be replaced and are not in the consonants list.
To do this, I would use an if-else instead of an if in your loop. This will allow you to replace letters that are in the consonants list and add letters that don't need to be replaced to the final word.
It would look something like this:
Note that the consonants list has the characters that are to be replaced in word word.
This should give you what you are looking for.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
The community is reviewing whether to reopen this question as of 2 years ago.
Improve this question
I'm experimenting with command line arguments in Rust.
Windows Power Shell.
if let Some(a) = env::args().nth(1) {
println!("parâmetro é {:?}", &a);
} else ...
ARG = "Qu'il" prints "parâmetro é Qu\'il" (ok)
ARG = Qu'il (results in apparent infinite loop)
ARG = Qu\il (idem)
So, what's the proper way to handle this (the error)?
Thanks in advance.
I can't really discern what error you are referring to, so I'll explain the reasoning for the behavior you are seeing:
You are using the format specifier {:?} which makes Rust print the string in a debug-friendly manner. If you use println!("parâmetro é {}", &a); instead you'd see parâmetro é Qu'il
This is not an infinite loop. Apostrophes (') are special characters in PowerShell to define a literal string. The reason why nothing is happening is that PowerShell is waiting for you to write the rest of the string and finish with another apostrophe.
Like nr. 1
See more here:
About literal strings in PowerShell
Can I use a single quote in a PowerShell 'string'?
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I'm using following regex to validate name:
^[a-zA-Z]{1}[a-zA-Z.' ]{1,20}$
Single quote is mentioned in the second range. However, when I validate a string against this regex, single quote (') invalidates the match. Here's my code:
let nameRegEx = "^[a-zA-Z]{1}[a-zA-Z.' ]{1,21}$"
let nameTest = NSPredicate(format:"SELF MATCHES %#", nameRegEx)
let isNameValid = nameTest.evaluate(with: name)
I've tried \' but no use.
Turns out textField.text returns ’ and not '. Changing the character resolved the issue.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Numeric literals can contain extra formatting to make them easier to read. Both integers and floats can be padded with extra zeroes and can contain underscores to help with readability. Neither type of formatting affects the underlying value of the literal:
let paddedDouble = 000123.456
let oneMillion = 1_000_000
let justOverOneMillion = 1_000_000.000_000_1
Well for one thing not all locales separate numbers with commas. Moreover, using comma separators could become confusing syntactically; consider the following function call:
foo(123,456)
Is it one literal 123,456, or two distinct arguments 123 and 456?
Reason #1: Commas would be ambiguous – it would be impossible to distinguish the following cases:
var prices: [Double] = [1,234.00, 99.99]
# evaluates to
var prices: [Double] = [1.00, 234.00, 99.99]
However underscores are not ambiguous in this case:
var prices: [Double] = [1_234.00, 99.99]
Reason #2: The underscore is generally used to indicate a discarded value which makes sense in this context (it is essentially a discarded digit).
Reason #3: Swift is inspired by Ruby, which does the same thing.
I am not a Swift language designer (and I'm not sure anyone who is posts on SO in any official capacity, so this might not be the best place for directing questions at them), but I have a couple of guesses:
the comma is an operator in Swift (works about the same as in C)
not everybody uses comma as the thousands separator
you can use underscore to break up any numeric literal in any way that helps it be readable to you, not just as a thousands separator
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have this character.
–
How to convert this character to unicode?
Sorry if it is a silly question.
It's not a silly question, character encoding can be tricky to get your head around. I highly recommend reading The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) (I'm sure you can guess the topic).
Unicode itself isn't an encoding, it's a very long list of characters and code points. What I'm guessing you want to do is display the dash character in some way. Where are you wanting to display or store the data? If it's in a browser, then that representation should work as that's the HTML encoded version. If you want to store it in a database then you'll need to convert that encoded version to a string and then convert that string to whatever encoding the database is using.
Take a look at this source has the encoding in different formats
http://www.fileformat.info/info/unicode/char/2013/index.htm
but each language has its own rules on how to write this in a string/char literal