我想知道在URL路径中使用大小写和空格是什么的好习惯。
套管:
间距:
../data/upload_data
../data/upload-data
../data/uploadData
../Data/UploadData
Run Code Online (Sandbox Code Playgroud)
你怎么看?哪个更好?
我创建了以下方法,该方法首先使用NSString上的内置convertStringToTitleCase方法,但它实际上只是将每个单词的第一个字母大写.我在.NET中看到TextInfo.ToTitleCase有一种方法可以尝试我想用Objective-C做什么,但也不尽如人意.
http://msdn.microsoft.com/en-us/library/system.globalization.textinfo.totitlecase.aspx
我写的开始的方法如下.你如何正确处理大写字符串?将数据库转换为全部大写/小写有帮助吗?
- (NSString *)convertStringToTitleCase:(NSString *)str {
NSMutableString *convertedStr = [NSMutableString stringWithString:[str capitalizedString]];
NSRange range = NSMakeRange(0, convertedStr.length);
// a list of words to always make lowercase could be placed here
[convertedStr replaceOccurrencesOfString:@" De "
withString:@" de "
options:NSLiteralSearch
range:range];
// a list of words to always make uppercase could be placed here
[convertedStr replaceOccurrencesOfString:@" Tv "
withString:@" TV "
options:NSLiteralSearch
range:range];
return convertedStr;
}
Run Code Online (Sandbox Code Playgroud) 我对这些映射感到困惑:
map <c-c>
map <C-C>
map <c-C>
map <C-c>
Run Code Online (Sandbox Code Playgroud)
他们有什么不同吗?编写此映射的正确方法是什么?
同样的问题:
map <s-Tab>
map <S-TAB>
map <s-tab>
Run Code Online (Sandbox Code Playgroud) 好的,我有一个相当简单的(至少看起来很简单).我有一个多线的字符串,我只是在用其他东西替换不同的单词.让我演示给你看...
#!/usr/bin/perl -w
use strict;
$_ = "That is my coat.\nCoats are very expensive.";
s/coat/Hat/igm;
print;
Run Code Online (Sandbox Code Playgroud)
输出将是
That is my Hat
Hats are very expensive...
第一行的"帽子"不应大写.是否有任何技巧可以使套管符合英语的编写方式?谢谢 :)
我只是好奇相同的类型转换格式适用于 char、int 以及其他许多类型,但为什么它不适用于字符串,即(string) 'c'屏幕后面出了什么问题?
#include <iostream>
using namespace std;
int main(){
char a = 'a';
cout << (char) 99 <<endl;
cout << (int) 'c'<<endl;
cout<< (string) 'c' + "++" <<endl; // why this does not work???
cout<< string (1, 'c') + "++" <<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)