string-conversion

Convert single byte character string (half width) to double byte (full width)

冷暖自知 提交于 2019-12-12 18:18:38
问题 Recently I came across this code in a C# application. cDataString = Strings.StrConv(cDataString, VbStrConv.Wide); I understand that the StrConv is a string function of VB. You can call it by including 'using Microsoft.VisualBasic;'. It is supposed to covert half width japanese characters into full width ones. My question is: Is there a way to achieve the same WITHOUT using the VB functions and WITHOUT including the VB headers, using only the standard c# functions? I know there are many c#

wstringstream to LPWSTR

孤街醉人 提交于 2019-12-11 07:43:09
问题 I have built up a string using wstringstream and need to assign it to a member of a struct of type LPWSTR . I try to use my_stringstream.str().c_str() but get the following compile time error: cannot convert from 'const wchar_t *' to 'LPWSTR' How can I do this? I have tried many different combinations of casts with either more compile time errors or random jargon when I try and display the string in a GUI. 回答1: Your function expects a pointer to modifiable data, i.e. wchar_t* , but the

Converting a string of numbers to hex and back to dec pandas python

旧城冷巷雨未停 提交于 2019-12-11 04:53:08
问题 I currently have a string of values which I retrieved after filtering through data from a csv file. ultimately I had to do some filtering of the data but I have the same numbers as a list, dataframe, or array. I just need to take the numbers in the string and convert them to hex and then take the first 8 numbers of the hex and convert that to dec for each element in the string. Lastly I also need to convert the last 8 of the same hex and then to dec as well for each value in the string. I

PHP: Convert specific-Bosnian characters to non-bosnian (utf8 standard chars)

浪子不回头ぞ 提交于 2019-12-11 02:05:23
问题 In Bosnia we have following characters only used in latin-form in Bosnia and Croatia, so I'd need to convert these letters as following: FROM | TO ć | c č | c ž | z š | s đ | dj If this is possible with some special form of RegEx, or utf8_encode/decode, that informatiion and an appopriate example will be quite welcome! Thanks all. PS - Want to achive this in PHP! 回答1: You can use this with iconv. $result = iconv("UTF-8", "ASCII//TRANSLIT", $text); That will work assuming your input $text is

What occurs when a string is converted to a byte array

主宰稳场 提交于 2019-12-10 11:03:49
问题 I think that this is a newbie type question but I have quite understood this. I can find many posts on how to convert a string to a byte array in various languages. What I do not understand is what is happening at a character by character basis. I understand that each character displayed on the screen is represented by a number such as it's ascii code. (Can we stick with ASCII at the moment so I get this conceptually :-)) Does this mean that when I want to represent a character or a string

String.getBytes(charset) has errors for EBCDIC-charset

ぐ巨炮叔叔 提交于 2019-12-09 18:58:27
问题 The String-conversion to EBCDIC via String.getBytes(charset) supplys at least one false result. The character "a" becomes a 0x3f but should be 0x81. public static void convert() throws UnsupportedEncodingException { String data="abcABC"; String ebcdic = "IBM-1047"; String ascii = "ISO-8859-1"; System.out.printf("Charset %s is supported: %s\n", ebcdic, Charset.isSupported(ebcdic)); String result= new String(data.getBytes(ebcdic)); System.out.printf("EBCDIC: %s\n",asHex(result.getBytes()));

inconsistency in converting string to integer, when string is hex, prefixed with '0x'

泄露秘密 提交于 2019-12-09 01:00:09
问题 Using PHP 5.3.5. Not sure how this works on other versions. I'm confused about using strings that hold numbers, e.g., '0x4B0' or '1.2e3' . The way how PHP works with such strings seems inconsistent to me. Is it only me? Or is it a bug? Or undocumented feature ? Or am I just missing some magic sentence in docs? <?php echo $str = '0x4B0', PHP_EOL; echo "is_numeric() -> ", var_dump(is_numeric($str)); // bool(true) echo "*1 -> ", var_dump($str * 1); // int(1200) echo "(int) -> ", var_dump((int)

What occurs when a string is converted to a byte array

风格不统一 提交于 2019-12-06 14:24:28
I think that this is a newbie type question but I have quite understood this. I can find many posts on how to convert a string to a byte array in various languages. What I do not understand is what is happening at a character by character basis. I understand that each character displayed on the screen is represented by a number such as it's ascii code. (Can we stick with ASCII at the moment so I get this conceptually :-)) Does this mean that when I want to represent a character or a string (which is a list of chartacters) the following occurs Convert character to ASCII value > represent ascii

MYSQL: How to convert a string into a month (Number) [duplicate]

我只是一个虾纸丫 提交于 2019-12-06 08:53:44
问题 This question already has answers here : MySQL MONTHNAME() from numbers (5 answers) Closed 6 years ago . I have the short version of months: JAN, FEB, MAR , etc. and would like to convert them to it's respective numeric value: 1, 2, 3 , etc Also, I would like to be able to change back and forth between the numeric-month-value, to a "short" month name ( JAN, FEB, MAR ) and it's long version ( January, February, March , etc) NOTE: As @dipu-raj pointed out, this is not a duplicate because I am

How can I convert a REG_BINARY value from the registry into a string ? (vb.net)

半城伤御伤魂 提交于 2019-12-06 06:57:51
I have a registry value which is stored as a binary value (REG_BINARY) holding information about a filepath. The value is read out into an byte array. But how can I transform it into a readable string? I have read about system.text.encoding.ASCII.GetString(value) but this does not work. As far as I got to know the registry value is arbitrary binary data and not ASCII which is the reason for the method to produce useless data. Does anybody know how I can convert the data? Sample: (A piece of the entry) 01 00 00 00 94 00 00 00 14 00 00 00 63 00 3A 00 5C 00 70 00 72 00 6F 00 67 00 72 00 61 00 6D