Originally Posted by mnakleh
tbl = arcpy.CreateScratchName("","","table","in_memory")
Rows = arcpy.InsertCursor(tbl)
Row = Rows.newRow()
del Row, Rows
arcpy.CalculateField_management(tbl,"TESTFIELD","chr(10) + chr(13)","PYTHON_9.3")
Rows = arcpy.SearchCursor(tbl)
Row = Rows.next()
print "Field value: ",repr(Row.TESTFIELD)
del Row, Rows
Also this worked fine for me:
Executing: CalculateField in_memory\xx0 TESTFIELD "chr(10) + chr(13)" PYTHON_9.3 #
Start Time: Mon Aug 05 10:49:33 2013
Succeeded at Mon Aug 05 10:49:33 2013 (Elapsed Time: 0.00 seconds)
Field value: u'\n\r'
I think the problem you're running into is using the value of the field !TESTFIELD! if the field contains newlines - the tool will substitute in the value of the field into the expression - the geoprocessing messaging and Python interpreter can't deal with this.
I think the method you found is a good approach, that is, using Python with cursors (using the Calculate Value tool if in ModelBuilder) instead of using Calculate Field. I don't see another way around this, which is a design issue with the way Calculate Field accesses field values, and its connection with the geoprocessing message environment in how things are passed to Python.
Seems to me this is a good enhancement request for Calculate Field, i.e. have non printables converted to escape codes as part of the !FIELDNAME! -> value substitution process.