Jump to content
Sign in to follow this  
LoOni3r

character location name tanmoa

Recommended Posts

Hello everyone,

 

i work a lot with the names of the locations, for example Oua-Oué.

I use a file based "database". When creating file names with é will that é replaced by Ã©.

this is because the API between arma 3 and c ++ is too old to convert utf8

 

Now i want é replace by e with splitString.

splitString give me  2x ""instead of  é out.

So I cannot replace it before handing it over to the database

 

temp.png

 

	_locnamearr = _locname splitString "";
	private _letter = "";
	{
		systemchat _x;
	}forEach _locnamearr;

 

 

is there any other way to replace the é in e?

 

Many Thanks.

- greetings

 

Share this post


Link to post
Share on other sites
private _string = "hélloWorld";
private _cleanedArr = [];
{
if (_x == 233) then {
_cleanedArr pushBack 101;
} else {
_cleanedArr pushBack _x;
}; 
} forEach toArray _string;

private _cleaned = toString _cleanedArr;
_cleaned //=> helloWorld

Not exactly the cleanest solution but it works.  There must be a better way of doing it though.

Share this post


Link to post
Share on other sites

Thank you very much, that first helped me.
are these DIK KeyCodes? how did you find out what is 233 and 101?

 

 

eidt:\\ Roger that. ToArray converts to numbers.

Share this post


Link to post
Share on other sites

sometimes i miss good old php ...

 

I created a function. Works well so far.

 

FNC_PUBLIC_CHANGE_CHARACTER = {
	params ["_string"];
	switch (true) do {
		case ("'" in _string): {
			private _cleanedArr = [];
			{
				if (_x isEqualTo 39) then {
				} else {
					_cleanedArr pushBack _x;
				}; 
			}forEach toArray _string;
			_string = toString _cleanedArr;
		};
		case ("é" in _string): {
			private _cleanedArr = [];
			{
				if (_x isEqualTo 233) then {
					_cleanedArr pushBack 101;
				} else {
					_cleanedArr pushBack _x;
				}; 
			}forEach toArray _string;
			_string = toString _cleanedArr;
		};
		case ("ä" in _string): {
			private _cleanedArr = [];
			{
				if (_x isEqualTo 228) then {
					_cleanedArr pushBack 79;
					_cleanedArr pushBack 101;
				} else {
					_cleanedArr pushBack _x;
					
				}; 
			}forEach toArray _string;
			_string = toString _cleanedArr;
		};
		case ("Ä" in _string): {
			private _cleanedArr = [];
			{
				if (_x isEqualTo 196) then {
					_cleanedArr pushBack 65;
					_cleanedArr pushBack 69;
				} else {
					_cleanedArr pushBack _x;
				}; 
			}forEach toArray _string;
			_string = toString _cleanedArr;
		};
		case ("ö" in _string): {
			private _cleanedArr = [];
			{
				if (_x isEqualTo 246) then {
					_cleanedArr pushBack 111;
					_cleanedArr pushBack 101;
				} else {
					_cleanedArr pushBack _x;
					
				}; 
			}forEach toArray _string;
			_string = toString _cleanedArr;
		};
		case ("Ö" in _string): {
			private _cleanedArr = [];
			{
				if (_x isEqualTo 214) then {
					_cleanedArr pushBack 79;
					_cleanedArr pushBack 69;
				} else {
					_cleanedArr pushBack _x;
				}; 
			}forEach toArray _string;
			_string = toString _cleanedArr;
		};
		case ("ü" in _string): {
			private _cleanedArr = [];
			{
				if (_x isEqualTo 252) then {
					_cleanedArr pushBack 171;
					_cleanedArr pushBack 101;
				} else {
					_cleanedArr pushBack _x;
					
				}; 
			}forEach toArray _string;
			_string = toString _cleanedArr;
		};
		case ("Ü" in _string): {
			private _cleanedArr = [];
			{
				if (_x isEqualTo 220) then {
					_cleanedArr pushBack 85;
					_cleanedArr pushBack 69;
				} else {
					_cleanedArr pushBack _x;
				}; 
			}forEach toArray _string;
			_string = toString _cleanedArr;
		};
	};
	_string
};

 

Share this post


Link to post
Share on other sites

That just hurts to look at:

FNC_PUBLIC_CHANGE_CHARACTER = {
	params ["_string"];
	
	private _cleanedArr = [];
	{
		switch (_x) do {
			case 39: {break;};
			case 233: {_cleanedArr pushBack 101; break;};
			case 228: {
				_cleanedArr pushBack 79;
				_cleanedArr pushBack 101;
				break;
			};
			case 196: {
				_cleanedArr pushBack 65;
				_cleanedArr pushBack 69;
				break;
			};
			case 246: {
				_cleanedArr pushBack 111;
				_cleanedArr pushBack 101;
				break;
			};
			case 214: {
				_cleanedArr pushBack 79;
				_cleanedArr pushBack 69;
				break;
			};
			case 252: {
				_cleanedArr pushBack 171;
				_cleanedArr pushBack 101;
				break;
			};
			case 220: {
				_cleanedArr pushBack 85;
				_cleanedArr pushBack 69;
				break;
			};
			default {
				_cleanedArr pushBack _x;
			};
		};
	} forEach toArray _string;
	
	toString _cleanedArr
};

 

Share this post


Link to post
Share on other sites

Guys? Will you guys just ignore about forceUnicode? This works completely fine for me.

  • Haha 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×