Notifications
Clear all

[Closed] Changing local characters to ASCII standard?

Hi,

Is there any way in mxs to change the local characters to ASCII standard?

Eg, here in Poland we have characters like: ż, ż, ó… and many more. Can I replace them somehow to: z, z, o… and so on?

4 Replies

For some scripts I’m using this function. It uses two arrays: one with characters you want to replace and the other with the characters you want to replace them with. Then it goes over a string character by character. It serves my purpose, but it might be too slow when you’re doing a lot of strings.
My function is geared towards French characters. But these might cover the Polish characters, or at least give you a head start:
AccChars= “ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðñòóôõöùúûüýÿ”
RegChars= “SZszYAAAAAACEEEEIIIIDNOOOOOUUUUYaaaaaaceeeeiiiidnooooouuuuyy”

function fn_sanitizeString theInputString =
(
	/*<FUNCTION>
	Description:
		edits a string. Accented characters and other characters are edited in such a way
		that the obj fileformat accepts it. This is especially needed in objectnames, materialnames and bitmaptexture filenames.
		Replaces whitespaces with underscores
		added some illegal URI characters. Needed to process the URI's stored in the collada files  http://www.ietf.org/rfc/rfc3986.txt 
	Arguments:
		<string> theInputString: the string to edit
	Return:
		<string> the edited string
	</FUNCTION>*/
	
	--TODO: findstring is case-insensitive. Either leave it at that or try to fix it with some dotnet thing
	local theBad = "àèìòùÀÈÌÒÙäëïöüÄËÏÖÜâêîôûÂÊÎÔÛáéíóúÁÉÍÓÚðÐýÝãñõÃÑ՚ŠžŽçÇåÅøØ :/?#[]@!$&'()*+,;="
	local theGood = "aeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUdDyYanoANOsSzZcCaAoO___________________"
	local theOutputString = copy theInputString
	
	for i = 1 to theOutputString.count do
	(
		local theBadCharIndex = findString theBad theOutputString[i]
		if theBadCharIndex != undefined do theOutputString[i]=theGood[theBadCharIndex]
	)
	
	theOutputString
)

Yeah I was hoping to avoid replacement with arrays. But I guess its the only option :(?

there’s always an option

Interesting. I will take some time to look into this Its dotNET right? Im not a big fan of dotNET but if it does its job than Im more than happy