Pine script conditions / conditional-statements - if-statement

I have 6 conditions:
c1 = ...
c2 = ...
Then if 4 of them are fullfilled (yielding 15 combinations), I will execute some command. How to do this?
E.g.:
cb1 = c1 and c2 and c3 and c4
cb2 = c1 and c2 and c3 and c5
cb3 = c1 and c2 and c3 and c6
cb4 = c1 and c2 and c4 and c5
cb5 = c1 and c2 and c4 and c6
cb6 = c1 and c2 and c5 and c6
cb7 = c1 and c3 and c4 and c5
cb8 = c1 and c3 and c4 and c6
cb9 = c1 and c3 and c5 and c6
cb10 = c1 and c4 and c5 and c6
cb11 = c2 and c3 and c4 and c5
cb12 = c2 and c3 and c4 and c6
cb13 = c2 and c3 and c5 and c6
cb14 = c2 and c4 and c5 and c6
cb15 = c3 and c4 and c5 and c6
// Set up alert
alertcondition(condition=cb1 or cb2 or cb3 or cb4 or cb5 or cb6 or cb7 or cb8 or cb9 or cb10 or cb11 or cb12 or cb13 or cb14 or cb15,
message="cb")

You can read this for some information.
if (condition1 == true) and (condition2 == true) and (condition3 == true) and (condition4 == true)
// Do something
else if (condition2 == true) and (condition3 == true) and (condition4 == true) and (condition5 == true)
// Do something else
Please note the indentation.

Could we do the point system? example
condition1 is ok X=1
condition2 is ok X=x+1
condition3 is ok X=x+3
condition4 is ok X=x+4
if x>0
do this
else if x>1
do this
else if x>2
do this
...

Related

print and save matrix in fortran

Hello everyone I am new to Fortran and I am facing a problem. Let s assume I have a matrix a(5,50)
a1 a2 a3 a4 a5 a6 a7 etc
b1 b2 b3 b4 b5 b6 b7 etc
c1 c2 c3 c4 c5 c6 c7 etc
d1 d2 d3 d4 d5 d6 d7 etc
e1 e2 e3 e4 e5 e6 e7 etc
is there a way to save it into a file and print the matrix like the following
a1 b1 c1 d1 e1
a2 b2 c2 d2 e2
a3 b3 c3 d3 e3
etc
without saving it to another matrix? Because ok i can always do a loop and save it to a new matrix and then save that to a file and print it. I have also created a subroutine to print my matrix in a correct order and be presentable
Sure.
You could loop over the first index, then write the whole column:
do ii = 1, 50
write(unit, '(5(I7))') a(ii, :)
end do
Or you could use transpose:
write(unit, '(5(I7))') transpose(a)
(I'm assuming that a is an integer array and that all values can be written with 6 or fewer digits (including sign). Change the format if that's not the case.)
This computer doesn't have a fortran compiler, so I haven't tested it, but it should work.
Cheers

Merging lines in chess ply sequences

I have a file containing the ply sequences of multiple chess games. Games are separated by one or more new lines and the corresponding ply sequence of each game can be also split into multiple lines.
I would like to merge all lines corresponding to the same game, so as to have only one line per game. I have tried different options, but none worked. A remark is that the file contains more than 14M games, so I need a fast solution. I work on Linux.
Example:
e4 e5 Bb5 c6 Bc4 b5 Bxf7+ Kxf7 Nf3 Qf6 d4 d6 dxe5 dxe5
Bg5 Qe6 Nc3 Be7 Be3 Nf6 b4 Rd8 Ng5+ Kg8 Nd5 Qd6 Qf3 cxd5
Bc5 Qe6 Nxe6 Bxe6 Bxe7
e4 e5 Nf3 Qf6 Bc4 Bc5 Nc3 c6 Na4 Bb4 c3 Ba5 Nc5 d6 Nb3
Bb6 d4 h6 dxe5 dxe5 O-O Ne7 Be3 Nd7 Bxb6 Nxb6 Be2 O-O
Nc5 Ng6 b4 Nf4 Nd3 Rd8 Qc2 Nc4 Nxf4 Na3 Qb3 Qxf4
Qxa3 Qxe4 Rfe1 f6 Qb3+ Kh8 Bd1 Qf4 Bc2 Bg4 Re4 Qf5 Rxe5
Qd7 Re3 Qd6 Nh4 Qd5 Ng6+ Kh7 Ne7+ f5 Nxd5 Rxd5 c4 Rd2
h3 Bh5 Bxf5+ Kh8
e4 e5 Nf3 Nc6 Bb5 Nf6 Bxc6 bxc6 O-O d6 h3 Nxe4 Re1 Bf5
d4 f6 dxe5 fxe5 Nbd2 Nxd2 Bxd2 Be7 Qc1 O-O c3 h6 c4 e4
Nd4 Qd7 b3 d5 Nxf5 Qxf5 Be3 Bf6 Rb1 d4 Bd2 c5
d4 Nf6 Nc3 d5 Bg5 Ne4 Nxe4 dxe4 c3 h6 Be3 e6 Qc2 f5 g4
Be7 Bg2 O-O O-O-O Nd7 d5 Nb6 dxe6 Qe8 gxf5 Rxf5 Bxe4 Rf8
Bh7+ Kh8 Bg6
Should become:
e4 e5 Bb5 c6 Bc4 b5 Bxf7+ Kxf7 Nf3 Qf6 d4 d6 dxe5 dxe5 Bg5 Qe6 Nc3 Be7 Be3 Nf6 b4 Rd8 Ng5+ Kg8 Nd5 Qd6 Qf3 cxd5 Bc5 Qe6 Nxe6 Bxe6 Bxe7
e4 e5 Nf3 Qf6 Bc4 Bc5 Nc3 c6 Na4 Bb4 c3 Ba5 Nc5 d6 Nb3 Bb6 d4 h6 dxe5 dxe5 O-O Ne7 Be3 Nd7 Bxb6 Nxb6 Be2 O-O Nc5 Ng6 b4 Nf4 Nd3 Rd8 Qc2 Nc4 Nxf4 Na3 Qb3 Qxf4 Qxa3 Qxe4 Rfe1 f6 Qb3+ Kh8 Bd1 Qf4 Bc2 Bg4 Re4 Qf5 Rxe5 Qd7 Re3 Qd6 Nh4 Qd5 Ng6+ Kh7 Ne7+ f5 Nxd5 Rxd5 c4 Rd2 h3 Bh5 Bxf5+ Kh8
e4 e5 Nf3 Nc6 Bb5 Nf6 Bxc6 bxc6 O-O d6 h3 Nxe4 Re1 Bf5 d4 f6 dxe5 fxe5 Nbd2 Nxd2 Bxd2 Be7 Qc1 O-O c3 h6 c4 e4 Nd4 Qd7 b3 d5 Nxf5 Qxf5 Be3 Bf6 Rb1 d4 Bd2 c5
d4 Nf6 Nc3 d5 Bg5 Ne4 Nxe4 dxe4 c3 h6 Be3 e6 Qc2 f5 g4 Be7 Bg2 O-O O-O-O Nd7 d5 Nb6 dxe6 Qe8 gxf5 Rxf5 Bxe4 Rf8 Bh7+ Kh8 Bg6
With awk, you can set the record separator to the empty string, which makes records being separated by blank lines. Then you replace for each record the newlines with a space:
awk -v RS="" '{gsub("\n", " ")} 1' infile
Or, as an alternative, with sed:
sed ':a;N;/\n$/!s/\n//;ta;s/\n$//;/^$/d' infile
This works as follows:
:label # Label to jump back to
N # Append next line to pattern sapce
/\n$/! s/\n// # If pattern space does not end with newline, remove newline
t label # Jump back to label if we changed something
s/\n$// # Remove trailing newline
/^$/ d # Delete empty line
The last command isn't strictly necessary for the given input, but if there are more than two consecutive empty lines, there would be empty output lines without it. It's just there to make the sed command equivalent to the awk command.

Loop interval changing unexpectedly

I am writing a loop to remove every third element from an array until there is only one element left.
here is the code...
int elimcnt = 1;//counts how many elements looped through
int cnt = 0;//counts how many elements deleted for printing purposes
for (int i = 0; v.size() > 1; i++, elimcnt++) {
if (i == v.size()) {//reset i to the beginning when it hits the end
i = 0;
}
if (elimcnt%in.M == 0 && elimcnt != 0) {//in.M is elimination index which is 3
v.erase(v.begin() + (elimcnt%v.size()) - 1);
cnt++;
if (cnt%in.K == 0) {//in.K is how often you will print which is after 7 deletes
print_vector(v, cnt);
}
}
}
what actually happens when i run it is that it will correctly delete the first element but after that it deletes every 4th element from there on out.
Here is an example input...
A1 A2 A3 A4 A5 A6 A7 A8 A9 B1 B2 B3
B4 B5 B6 B7 B8 B9 C1 C2 C3 C4 C5 C6
C7 C8 C9 D1 D2 D3 D4 D5 D6 D7 D8 D9
E1 E2 E3 E4 E5
What is supposed to be outputted...
A1 A2 A4 A5 A7 A8 B1 B2 B4 B5 B7 B8
C1 C2 C4 C5 C6 C7 C8 C9 D1 D2 D3 D4
D5 D6 D7 D8 D9 E1 E2 E3 E4 E5
This is what is actually outputted...
A1 A2 A4 A5 A6 A8 A9 B1 B3 B4 B5 B7
B8 B9 C2 C3 C4 C6 C7 C8 D1 D2 D3 D4
D5 D6 D7 D8 D9 E1 E2 E3 E4 E5
I cant seem to figure out what is causing the code to do this so any help will be greatly appreciated.
The problem is in the expression used in the statement
v.erase(v.begin() + (elimcnt%v.size()) - 1);
^^^^^^^^^^^^^^^^^^^^^
Consider a sequence of numbers
1, 2, 3, 4, 5, 6
For the first traversing of the sequence You need to delete 3 and 6
After deleting 3 you will get
1, 2, 4, 5, 6
and the variable elimcnt after the deleting will be incremented and will be equal to 4. However the size of the sequence is now equal to 5. So when elimcnt will be equal to 6 then the expression elimcnt%v.size()) - 1 will be equal to 0 and the element 1 will be deleted.
I could suggest a more safe approach using iterators.
for example
size_t elimcnt = 0;//counts how many elements looped through
size_t cnt = 0;
for (auto it = v.begin(); v.size() > 1; it == v.end() ? it = v.begin() : it )
{
if (++elimcnt % in.M == 0)
{
it = v.erase(it);
if (++cnt % in.K == 0)
{
print_vector(v, cnt);
}
}
else
{
++it;
}
}

C++ Matrix horizontal concat

I have 2 matrix, for example:
a1 a2 a3 a4 a5 a6 a7 a8
M1 = b1 b2 b3 b4 M2 = b5 b6 b7 b8
c1 c2 c3 c4 c5 c6 c7 c8
what i want is get a matrix concat like this:
a1 a2 a3 a4 a5 a6 a7 a8
Mr = b1 b2 b3 b4 b5 b6 b7 b8
c1 c2 c3 c4 c5 c6 c7 c8
fast as possible cause my program is all based on this concat at speed of 50MHz.(Sound acquisition)
It's actually neded for read a single line fast(each line is a microphone flow).
If you save your matrix as a std::vector<std::vector<double>>, where the inner vector is one of your rows, you can use std::insert to perform a concatenation of the rows of your matrices.
vector1.insert( vector1.end(), vector2.begin(), vector2.end() );
You might also find a library such as armadillo useful. I has a function join_rows( A, B ), which is doing, what you ask for. With some chance this will have a better performance, than what you can program yourself.

Change all accented letters to normal letters in C++

The question
How can you change all accented letters to normal letters in C++ (or in C)?
By that, I mean something like eéèêaàäâçc would become eeeeaaaacc.
What I've already tried
I've tried just parsing the string manually and replacing each one of them one by one, but I was thinking there has to be a better/simpler way that I am not aware of (that would garantee I do not forget any accented letter).
I am wondering if there is already a map somewhere in the standard library or if all the accented characters can easily be mapped to the "normal" letter using some mathematic function (ex. floor(charCode-131/5) + 61)).
char* removeAccented( char* str ) {
char *p = str;
while ( (*p)!=0 ) {
const char*
// "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
tr = "AAAAAAECEEEEIIIIDNOOOOOx0UUUUYPsaaaaaaeceeeeiiiiOnooooo/0uuuuypy";
unsigned char ch = (*p);
if ( ch >=192 ) {
(*p) = tr[ ch-192 ];
}
++p; // http://stackoverflow.com/questions/14094621/
}
return str;
}
You should first define what you mean by "accented letters" what has to be done is largely different if what you have is say some extended 8 bits ASCII with a national codepage for codes above 128, or say some utf8 encoded string.
However you should have a look at libicu which provide what is necessary for good unicode based accented letters manipulation.
But it won't solve all problems for you. For instance what should you do if you get some chinese or russian letter ? What should you do if you get the Turkish uppercase I with point ? Remove the point on this "I" ? Doing so it would change the meaning of the text... etc. This kind of problems are endless with unicode. Even conventional sorting order depends of the country...
I know it only in theory. Basically, you perform Unicode normalization, then some decomposition, purge all diacritics, and recompose again.
Assuming the values are just chars, I'd create an array with the desired target values and then just replace each character with the corresponding member in the array:
char replacement[256];
int n(0);
std::generate_n(replacement, 256, [=]() mutable -> unsigned char { return n++; });
replacement[static_cast<unsigned char>('é')] = 'e';
// ...
std::transform(s.begin(), s.end(), s.begin(),
[&](unsigned char c){ return replacement[c]; });
Since the question is also tagged with C: when using C you'd need to create suitable loops to do the same operations but conceptually it would just same way. Similarily, if you can't use C++ 2011, you'd just use suitable function objects instead of the lambda functions.
Obviously, the replacement array can be set up just once and using a smarter approach than what is outlined above. However, the principle should work. If you need to replace Unicode characters thing become a bit more interesting, though: For one, the array would be fairly large and in addition the character may need multiple words to be changed.
Here is what you can do using ISO/IEC 8859-1 (ASCII-based standard character encoding):
if code range is from 192 - 197 replace with A
if code range is from 224 - 229 replace with a
if code range is from 200 - 203 replace with E
if code range is from 232 - 235 replace with e
if code range is from 204 - 207 replace with I
if code range is from 236 - 239 replace with i
if code range is from 210 - 214 replace with O
if code range is from 242 - 246 replace with o
if code range is from 217 - 220 replace with U
if code range is from 249 - 252 replace with u
Supposing x is the code of the number, perform the following for capital letters:
y = floor((x - 192) / 6)
if y <= 2 then z = ((y + 1) * 4) + 61 else z = (y * 6) + 61
Perform the following for small letters:
y = floor((x - 224) / 6)
if y <= 2 then z = ((y + 1) * 4) + 93 else z = (y * 6) + 93
The final answer z is the ASCII code of the required alphabet.
Note that this method works only if you are using ISO/IEC 8859-1.
I am afraid there is no easy way around here.
In application I work on this was solved by using internal codepage tables, each codepage table (like 1250, 1251, 1252, etc) contained actual codepage letter and non-diacritic equivalent. Tables were auto generated using c#, it contains some classes that really make that easy (with some heuristics actually), also java allows to implement it quicly.
This was actually for multibyte data with codepages, but it could be used for UNICODE strings (by just searching all tables for given unicode letter).
My use case was needing to do a case-insensitive sort a long list of strings, where some of the strings might have diacriticals. So for instance I wanted "Añasco Municipio" to come right before "Anchorage Municipality", instead of coming right before "Abbeville County" as it was doing with a naive comparison.
My strings are encoded in UTF-8, but there's a chance that they might contain some extended ascii characters instead of proper UTF-8 Unicode. I could have promoted all strings to UTF-8, and then used a library that could do UTF-8 string comparison, but I wanted to have full control both for speed and for deciding exactly how diacritical characters are mapped to non-diacritical characters. (My choices include things like treating the masculine ordinal indicator as "o", and treating the copyright character as c.)
The "two-byte" codes below are UTF-8 sequences. The "one-byte" codes are extended ascii.
This is where I got the codes:
http://www.ascii-code.com/
http://www.endmemo.com/unicode/unicodeconverter.php
void SimplifyStringForSorting( string *s, bool changeToLowerCase )
{
// C0 C1 C2 C3 C4 C5 E0 E1 E2 E3 E4 E5 AA // one-byte codes for "a"
// C3 80 C3 81 C3 82 C3 83 C3 84 C3 85 C3 A0 C3 A1 C3 A2 C3 A3 C3 A4 C3 A5 C2 AA // two-byte codes for "a"
// C8 C9 CA CB E8 E9 EA EB // one-byte codes for "e"
// C3 88 C3 89 C3 8A C3 8B C3 A8 C3 A9 C3 AA C3 AB // two-byte codes for "e"
// CC CD CE CF EC ED EE EF // one-byte codes for "i"
// C3 8C C3 8D C3 8E C3 8F C3 AC C3 AD C3 AE C3 AF // two-byte codes for "i"
// D2 D3 D4 D5 D6 F2 F3 F4 F5 F6 BA // one-byte codes for "o"
// C3 92 C3 93 C3 94 C3 95 C3 96 C3 B2 C3 B3 C3 B4 C3 B5 C3 B6 C2 BA // two-byte codes for "o"
// D9 DA DB DC F9 FA FB FC // one-byte codes for "u"
// C3 99 C3 9A C3 9B C3 9C C3 B9 C3 BA C3 BB C3 BC // two-byte codes for "u"
// A9 C7 E7 // one-byte codes for "c"
// C2 A9 C3 87 C3 A7 // two-byte codes for "c"
// D1 F1 // one-byte codes for "n"
// C3 91 C3 B1 // two-byte codes for "n"
// AE // one-byte codes for "r"
// C2 AE // two-byte codes for "r"
// DF // one-byte codes for "s"
// C3 9F // two-byte codes for "s"
// 8E 9E // one-byte codes for "z"
// C5 BD C5 BE // two-byte codes for "z"
// 9F DD FD FF // one-byte codes for "y"
// C5 B8 C3 9D C3 BD C3 BF // two-byte codes for "y"
int n = s->size();
int pos = 0;
for ( int i = 0 ; i < n ; i++, pos++ )
{
unsigned char c = (unsigned char)s->at( i );
if ( c >= 0x80 )
{
if ( i < ( n - 1 ) && (unsigned char)s->at( i + 1 ) >= 0x80 )
{
unsigned char c2 = SimplifyDoubleCharForSorting( c, (unsigned char)s->at( i + 1 ), changeToLowerCase );
if ( c2 < 0x80 )
{
s->at( pos ) = c2;
i++;
}
else
{
// s->at( pos ) = SimplifySingleCharForSorting( c, changeToLowerCase );
// if it's a double code we don't recognize, skip both characters;
// this does mean that we lose the chance to handle back-to-back extended ascii characters
// but we'll assume that is less likely than a unicode "combining character" or other
// unrecognized unicode character for data
i++;
}
}
else
{
unsigned char c2 = SimplifySingleCharForSorting( c, changeToLowerCase );
if ( c2 < 0x80 )
{
s->at( pos ) = c2;
}
else
{
// skip unrecognized single-byte codes
pos--;
}
}
}
else
{
if ( changeToLowerCase && c >= 'A' && c <= 'Z' )
{
s->at( pos ) = c + ( 'a' - 'A' );
}
else
{
s->at( pos ) = c;
}
}
}
if ( pos < n )
{
s->resize( pos );
}
}
unsigned char SimplifyDoubleCharForSorting( unsigned char c1, unsigned char c2, bool changeToLowerCase )
{
// C3 80 C3 81 C3 82 C3 83 C3 84 C3 85 C3 A0 C3 A1 C3 A2 C3 A3 C3 A4 C3 A5 C2 AA // two-byte codes for "a"
// C3 88 C3 89 C3 8A C3 8B C3 A8 C3 A9 C3 AA C3 AB // two-byte codes for "e"
// C3 8C C3 8D C3 8E C3 8F C3 AC C3 AD C3 AE C3 AF // two-byte codes for "i"
// C3 92 C3 93 C3 94 C3 95 C3 96 C3 B2 C3 B3 C3 B4 C3 B5 C3 B6 C2 BA // two-byte codes for "o"
// C3 99 C3 9A C3 9B C3 9C C3 B9 C3 BA C3 BB C3 BC // two-byte codes for "u"
// C2 A9 C3 87 C3 A7 // two-byte codes for "c"
// C3 91 C3 B1 // two-byte codes for "n"
// C2 AE // two-byte codes for "r"
// C3 9F // two-byte codes for "s"
// C5 BD C5 BE // two-byte codes for "z"
// C5 B8 C3 9D C3 BD C3 BF // two-byte codes for "y"
if ( c1 == 0xC2 )
{
if ( c2 == 0xAA ) { return 'a'; }
if ( c2 == 0xBA ) { return 'o'; }
if ( c2 == 0xA9 ) { return 'c'; }
if ( c2 == 0xAE ) { return 'r'; }
}
if ( c1 == 0xC3 )
{
if ( c2 >= 0x80 && c2 <= 0x85 ) { return changeToLowerCase ? 'a' : 'A'; }
if ( c2 >= 0xA0 && c2 <= 0xA5 ) { return 'a'; }
if ( c2 >= 0x88 && c2 <= 0x8B ) { return changeToLowerCase ? 'e' : 'E'; }
if ( c2 >= 0xA8 && c2 <= 0xAB ) { return 'e'; }
if ( c2 >= 0x8C && c2 <= 0x8F ) { return changeToLowerCase ? 'i' : 'I'; }
if ( c2 >= 0xAC && c2 <= 0xAF ) { return 'i'; }
if ( c2 >= 0x92 && c2 <= 0x96 ) { return changeToLowerCase ? 'o' : 'O'; }
if ( c2 >= 0xB2 && c2 <= 0xB6 ) { return 'o'; }
if ( c2 >= 0x99 && c2 <= 0x9C ) { return changeToLowerCase ? 'u' : 'U'; }
if ( c2 >= 0xB9 && c2 <= 0xBC ) { return 'u'; }
if ( c2 == 0x87 ) { return changeToLowerCase ? 'c' : 'C'; }
if ( c2 == 0xA7 ) { return 'c'; }
if ( c2 == 0x91 ) { return changeToLowerCase ? 'n' : 'N'; }
if ( c2 == 0xB1 ) { return 'n'; }
if ( c2 == 0x9F ) { return 's'; }
if ( c2 == 0x9D ) { return changeToLowerCase ? 'y' : 'Y'; }
if ( c2 == 0xBD || c2 == 0xBF ) { return 'y'; }
}
if ( c1 == 0xC5 )
{
if ( c2 == 0xBD ) { return changeToLowerCase ? 'z' : 'Z'; }
if ( c2 == 0xBE ) { return 'z'; }
if ( c2 == 0xB8 ) { return changeToLowerCase ? 'y' : 'Y'; }
}
return c1;
}
unsigned char SimplifySingleCharForSorting( unsigned char c, bool changeToLowerCase )
{
// C0 C1 C2 C3 C4 C5 E0 E1 E2 E3 E4 E5 AA // one-byte codes for "a"
// C8 C9 CA CB E8 E9 EA EB // one-byte codes for "e"
// CC CD CE CF EC ED EE EF // one-byte codes for "i"
// D2 D3 D4 D5 D6 F2 F3 F4 F5 F6 BA // one-byte codes for "o"
// D9 DA DB DC F9 FA FB FC // one-byte codes for "u"
// A9 C7 E7 // one-byte codes for "c"
// D1 F1 // one-byte codes for "n"
// AE // one-byte codes for "r"
// DF // one-byte codes for "s"
// 8E 9E // one-byte codes for "z"
// 9F DD FD FF // one-byte codes for "y"
if ( ( c >= 0xC0 && c <= 0xC5 ) || ( c >= 0xE1 && c <= 0xE5 ) || c == 0xAA )
{
return ( ( c >= 0xC0 && c <= 0xC5 ) && !changeToLowerCase ) ? 'A' : 'a';
}
if ( ( c >= 0xC8 && c <= 0xCB ) || ( c >= 0xE8 && c <= 0xEB ) )
{
return ( c > 0xCB || changeToLowerCase ) ? 'e' : 'E';
}
if ( ( c >= 0xCC && c <= 0xCF ) || ( c >= 0xEC && c <= 0xEF ) )
{
return ( c > 0xCF || changeToLowerCase ) ? 'i' : 'I';
}
if ( ( c >= 0xD2 && c <= 0xD6 ) || ( c >= 0xF2 && c <= 0xF6 ) || c == 0xBA )
{
return ( ( c >= 0xD2 && c <= 0xD6 ) && !changeToLowerCase ) ? 'O' : 'o';
}
if ( ( c >= 0xD9 && c <= 0xDC ) || ( c >= 0xF9 && c <= 0xFC ) )
{
return ( c > 0xDC || changeToLowerCase ) ? 'u' : 'U';
}
if ( c == 0xA9 || c == 0xC7 || c == 0xE7 )
{
return ( c == 0xC7 && !changeToLowerCase ) ? 'C' : 'c';
}
if ( c == 0xD1 || c == 0xF1 )
{
return ( c == 0xD1 && !changeToLowerCase ) ? 'N' : 'n';
}
if ( c == 0xAE )
{
return 'r';
}
if ( c == 0xDF )
{
return 's';
}
if ( c == 0x8E || c == 0x9E )
{
return ( c == 0x8E && !changeToLowerCase ) ? 'Z' : 'z';
}
if ( c == 0x9F || c == 0xDD || c == 0xFD || c == 0xFF )
{
return ( ( c == 0x9F || c == 0xDD ) && !changeToLowerCase ) ? 'Y' : 'y';
}
return c;
}