Replace function has no effect - replace

So the problem I am having right now is Replace function having no effect. The code is
param = WScript.Arguments(0)
param=Replace(param, "б", "vb")
MsgBox(param)
The second parameter is a cyrillic character (which I suspect could be the reason), yet I don't get any errors. It's just the output is literally the same as the input regardless of whether that б character occurs in the input or not

The reason why this problem occured was encoding indeed: changing UTF-8 to UTF-16 solved the problem without any further manipulations

Related

Unicode chars are printing, but not as expected

When i want a string containing a unicode char, i would normally do it with u8 before the string.
Since im making addons and gamemodes for a game, i usually need to use multibyte char set.
however, this project does not print unicode correctly, for instance, as a loading animation, i use a unicode char that is moved over periods. After applying some optimizations this no longer works.
case 1: game::functions.loadanim(XorStr(u8"•...... "), "Loading"); break;
but now, in place of printing the •, it prints â€Ç
all my unicode symbols have similar issues, project wide, some will actually print the unicode, but with unexpected results, when i try to append a degrees symbol, like this
XorStr("°");
it actually prints this
°
I have tried resaving all files as UTF-8 encoding, i have also tried changing encoding using the command line, if i dont use multibyte char set, it simply crashes, this was working fine before, and only changed after the optimization stuff in the property page, however, even after undoing all the changes in the property page, i still have this issue.
What did i break to cause this?

Right to left isolate string. C++

does anyone have experience in Unicodes?
I am facing a tough problem with Farsi unicodes.
I have an std::wstring s = (L"\u0634\u0646\u0628\u0647"); which is a Farsi word. When I debug it, I see that the underlying word is exactly what I want, but reversed. So I have researched and found that u2067 is for right to left reading the string.
NOTE:
I cannot reverse the string manually because Farsi characters are changing their shape regardless of their position in the string.
So I added the 2067 int the beginning and got
std::wstring s = (L"\u2067\u0634\u0646\u0628\u0647");.
But now the underlying string is the same , just added a square in the beginning if the string instead of reversing.
Does anyone have experince with this stuff? Please suggest a solution. Thanks!
The underlying string will be the same. You haven't changed the order of bytes, which is written right there in the code. But a renderer that understands Unicode should take those bytes and display the characters right-to-left. That's a visual thing. It has nothing to do with the encoding. From your question, it's not entirely clear what else you expected. It may be that you are viewing the string in a debugger, and the debugger does not support this feature of Unicode. If you try outputting the string to a proper console you ought to see it as you expect.

Decoding %E6%B0%94%E6%97%8B%E5%93%88%E5%88%A9.txt to a valid string

I am trying to decode a filename*= field of content disposition header. I get a string something like:
%E6%B0%94%E6%97%8B%E5%93%88%E5%88%A9.txt
What I have figured out that replacing % to \x works fine and I get the correct file name:
气旋哈利.txt
Is there a standard way of doing this in C++? Is there any library available to decode this?
I tried
boost::replace_all(name, "%x","\\x");
std::locale::generator gen;
std::locale locl = gen.generate("en_US.utf-8");
decoded_data = boost::locale::conv::from_utf( encoded_data, locl);
But it prints the replaced string instead of chinese characters.
\xE6\xB0\x94\xE6\x97\x8B\xE5\x93\x88\xE5\x88\xA9.txt
Any Idea where am I going wrong?
Replacing escape code like "\xE6" only work in string and character literals, not generally in strings. That's because it's handled by the compiler when it compiles the program.
However, it's not very hard to do yourself, using a simple loop that check for the '%' character, gets the next two characters and convert them to a number and use that number as a "character".

C++ Error-code <U+0013>

I have a function in C++ that I am testing, and after careful inspection I'm pretty sure everything is correct. However, I'm still getting a mysterious error relating to the "return" statement at the end of the function.
Where "population" is a real matrix (using the armadillo matrix package).
Looks like the error code represents a Unicode value. Check if the file is clean of characters which shouldn't be there (copy paste into notepad and then copy paste back).
You have accidentally managed to enter the Device Control 3 character (which has the unicode value U+0031) before return and after ;. The character is probably invisible for you, which is why you aren't seeing anything.
Replace those with spaces. You can probably turn your editor into some kind of "show invisibles" mode which might help.
If you are used to using Emacs keybindings and tried to Cx-s Cx-c to save and quit in another IDE ie Xcode it will insert odd unicode characters.

C++ random string values on declaration

I have a problem when using string.
This is my C++ code:
string s;
s = "..\inputs\Meknes_ext1\REF_WV02_12SEP15_ext1";
The compilation was successfully done, but when debugging, the string s takes random values like "hûJ" at the first line and then the affectation don't change his content.
How can I resolve this error?
You need to escape the escape character \, change this to \\:
s = "..\\inputs\\Meknes_ext1\\REF_WV02_12SEP15_ext1";
you need to escape the \ special character. Your string must be like that:
s = "..\\inputs\\Meknes_ext1\\REF_WV02_12SEP15_ext1";
I find out that this problem occur only when debugging, in the execution, the string takes the right value, note that I'm using the RelWithDebInfo mode. the explanation of this was find in: Visual Studio: Garbled debug watch of std::string's?