alphabet

How to enumerate the LOCALIZED alphabet in C#?

孤街醉人 提交于 2019-11-26 22:04:17
问题 First of all, this is not a duplicate of: Quickest way to enumerate the alphabet Because I need to get all the characters of the alphabet OF AN ARBITRARY (variable) LANGUAGE, and that in the correct ordering sequence. How can I do that without knowing the alphabet of every possible culture/language ? System.Gobalization.Cultureinfo for example has information on date format, and a sorting method, and codepage info. But not info on the alphabet itselfs. Forthermore 'A' to 'Z' ordering

Alphabet Range on Python

做~自己de王妃 提交于 2019-11-26 18:02:52
Instead of making a list of alphabet like this: alpha = ['a', 'b', 'c', 'd'.........'z'] Is there any way that we can group it to a range or something? For example, for numbers it can be grouped using range() range(1, 10) >>> import string >>> string.ascii_lowercase 'abcdefghijklmnopqrstuvwxyz' If you really need a list: >>> list(string.ascii_lowercase) ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] And to do it with range >>> list(map(chr, range(97, 123))) #or list(map(chr, range(ord('a'), ord('z')+1))) ['a',

Generating an array of letters in the alphabet

眉间皱痕 提交于 2019-11-26 12:21:01
问题 Is there an easy way to generate an array containing the letters of the alphabet in C#? It\'s not too hard to do it by hand, but I was wondering if there was a built in way to do this. 回答1: I don't think there is a built in way, but I think the easiest would be char[] alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray(); 回答2: C# 3.0 : char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray(); foreach (var c in az) { Console.WriteLine(c); } yes it does work even if the only

Alphabet Range on Python

好久不见. 提交于 2019-11-26 12:16:38
问题 Instead of making a list of alphabet like this: alpha = [\'a\', \'b\', \'c\', \'d\'.........\'z\'] Is there any way that we can group it to a range or something? For example, for numbers it can be grouped using range() range(1, 10) 回答1: >>> import string >>> string.ascii_lowercase 'abcdefghijklmnopqrstuvwxyz' If you really need a list: >>> list(string.ascii_lowercase) ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',

Quickest way to enumerate the alphabet

我只是一个虾纸丫 提交于 2019-11-26 09:29:31
问题 I want to iterate over the alphabet like so: foreach(char c in alphabet) { //do something with letter } Is an array of chars the best way to do this? (feels hacky) Edit: The metric is \"least typing to implement whilst still being readable and robust\" 回答1: (Assumes ASCII, etc) for (char c = 'A'; c <= 'Z'; c++) { //do something with letter } Alternatively, you could split it out to a provider and use an iterator (if you're planning on supporting internationalisation): public class

Convert integer into its character equivalent, where 0 => a, 1 => b, etc

岁酱吖の 提交于 2019-11-26 07:57:54
问题 I want to convert an integer into its character equivalent based on the alphabet. For example: 0 => a 1 => b 2 => c 3 => d etc. I could build an array and just look it up when I need it but I’m wondering if there’s a built in function to do this for me. All the examples I’ve found via Google are working with ASCII values and not a character’s position in the alphabet. 回答1: Assuming you want lower case letters: var chr = String.fromCharCode(97 + n); // where n is 0, 1, 2 ... 97 is the ASCII