What I use here the following:
def stringLegalize( text, joinchar=None, codif='utf-8' ):
"""
stringLegalize( text, joinchar, codif ) -> str
Replaces the illegal characters of a string for their respective
alternatives.
Special characters like bullets, etc are simply removed.
@param text: String
@oaram joinchar: String. Character to be used to replace spaces.
Default is None
@param codif: String. String representing the encoding type. Default
value is 'utf-8'
@return: String
"""
from unicodedata import normalize
legalstring = normalize( 'NFKD',
text.decode(codif)).encode('ASCII','ignore' )
if joinchar:
return joinchar.join( legalstring.split() )
else:
return legalstring
s = 'Braço do João 01'
stringLegalize( s, '_' )
>> 'Braco_do_Joao_01'
Hope it helps.
cheers,
diogo
On Mon, Jan 30, 2012 at 8:23 PM, J Bills <[email protected]> wrote:
> thanks JRAB! I knew there had to be something out there.
>
> I have an email into support asking for clarification, will report back if
> I get a definitive answer.
>
>
> On Sat, Jan 28, 2012 at 4:11 PM, John RA Benson <[email protected]> wrote:
>
>> Hey J -
>>
>> I don't know if this is what Nuke uses, but it seems to work for us where
>> there is potential for illegal chars:
>>
>> import re
>>
>> CHARFIX = re.compile("""[^\w]""")
>>
>> layerName = CHARFIX.sub('_', layerName)
>>
>> Cleans up the stuff that shouldn't be there for knobs and names. I've
>> been able to create illegal names (like your roto exporter?), but then the
>> names and knobs break or change to something legal when the script is
>> reloaded. It would be nice if it wasn't allowed in the first place.
>>
>> JRAB
>>
>> On Jan 28, 2012, at 2:51 AM, J Bills wrote:
>>
>> howdy! thought someone here might have the answer to this
>>
>> I'm trying to find out exactly what sort of node name filtering heuristic
>> that nuke runs oncreate
>>
>> We have a roto exporter that is somehow able to script illegal names in
>> nuke and all appears well at first but once you start trying to parent
>> expressions or whatnot, things quickly break. so I want to make sure our
>> naming from the roto app is getting the same filtering as it comes across
>> the Nuke.
>>
>> I couldn't find anything in the dev guide - anyone come across the info
>> before?
>>
>> thanks!
>> _______________________________________________
>> Nuke-python mailing list
>> [email protected], http://forums.thefoundry.co.uk/
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>
>>
>>
>> _______________________________________________
>> Nuke-python mailing list
>> [email protected], http://forums.thefoundry.co.uk/
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>
>>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python