case-conversion

C / C++ UTF-8 upper/lower case conversions

只谈情不闲聊 提交于 2019-11-28 23:20:24
The Problem: There is a method with a corresponding test-case that works on one machine and fails on the other (details below). I assume there's something wrong with the code, causing it to work by chance on the one machine. Unfortunately I cannot find the problem. Please note that the usage of std::string and utf-8 encoding are requirements I have no real influence on. Using C++ methods would be totally fine, but unfortunately I failed to find anything. Hence the use of C-functions. The method: std::string firstCharToUpperUtf8(const string& orig) { std::string retVal; retVal.reserve(orig.size

Javascript convert PascalCase to underscore_case

删除回忆录丶 提交于 2019-11-28 21:01:27
How can I convert PascalCase string into underscore_case string? I need conversion of dots to underscore as well. eg. convert TypeOfData.AlphaBeta into type_of_data_alpha_beta Avinash Raj You could try the below steps. Capture all the uppercase letters and also match the preceding optional dot character. Then convert the captured uppercase letters to lowercase and then return back to replace function with an _ as preceding character. This will be achieved by using anonymous function in the replacement part. This would replace the starting uppercase letter to _ + lowercase_letter. Finally

Javascript convert PascalCase to underscore_case

佐手、 提交于 2019-11-27 11:53:16
问题 How can I convert PascalCase string into underscore_case string? I need conversion of dots to underscore as well. eg. convert TypeOfData.AlphaBeta into type_of_data_alpha_beta 回答1: You could try the below steps. Capture all the uppercase letters and also match the preceding optional dot character. Then convert the captured uppercase letters to lowercase and then return back to replace function with an _ as preceding character. This will be achieved by using anonymous function in the

Converting camel case to underscore case in ruby

好久不见. 提交于 2019-11-27 02:42:11
Is there any ready function which converts camel case Strings into underscore separated string? I want something like this: "CamelCaseString".to_underscore to return "camel_case_string". ... jrhicks Rails' ActiveSupport adds underscore to the String using the following: class String def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end end Then you can do fun stuff: "CamelCase".underscore => "camel_case" abo-elleef You can use "CamelCasedName".tableize.singularize Or just "CamelCasedName".underscore Both options

How can I convert a string to upper- or lower-case with XSLT?

痴心易碎 提交于 2019-11-26 11:45:26
How do you do case conversion in XSL? <xsl:variable name="upper">UPPER CASE</xsl:variable> <xsl:variable name="lower" select="???"/> Jon W In XSLT 1.0 the upper-case() and lower-case() functions are not available. If you're using a 1.0 stylesheet the common method of case conversion is translate() : <xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" /> <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" /> <xsl:template match="/"> <xsl:value-of select="translate(doc, $lowercase, $uppercase)" /> </xsl:template> Anton Gogolev XSLT 2.0 has upper-case() and lower

Converting camel case to underscore case in ruby

别说谁变了你拦得住时间么 提交于 2019-11-26 10:08:10
问题 Is there any ready function which converts camel case Strings into underscore separated string? I want something like this: \"CamelCaseString\".to_underscore to return \"camel_case_string\". ... 回答1: Rails' ActiveSupport adds underscore to the String using the following: class String def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end end Then you can do fun stuff: "CamelCase".underscore => "camel_case" 回答2:

How can I convert a string to upper- or lower-case with XSLT?

爱⌒轻易说出口 提交于 2019-11-26 02:35:02
问题 How do you do case conversion in XSL? <xsl:variable name=\"upper\">UPPER CASE</xsl:variable> <xsl:variable name=\"lower\" select=\"???\"/> 回答1: In XSLT 1.0 the upper-case() and lower-case() functions are not available. If you're using a 1.0 stylesheet the common method of case conversion is translate() : <xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" /> <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" /> <xsl:template match="/"> <xsl:value-of select=