def view_i18n_helper(c, cluster, encoding, content):
 prefix = (cluster.fs_prefix + '/test_view_i18n')
 filename = (prefix + u'/test-view-car\xe1cter-internacional')
 bytestring = content.encode(encoding)
 try:
  f = cluster.fs.open(filename, 'w')
  f.write(bytestring)
  f.close()
  response = c.get(('/filebrowser/view=%s?encoding=%s' % (filename, encoding)))
  assert_equal(response.context['view']['contents'], content)
  response = c.get(('/filebrowser/view=%s?encoding=%s&end=8&begin=1' % (filename, encoding)))
  assert_equal(response.context['view']['contents'], unicode(bytestring[0:8], encoding, errors='replace'))
 finally:
  cleanup_file(cluster, filename)

def view_i18n_helper ( c , cluster , encoding , content ) : prefix = ( cluster . fs_prefix + '/test_view_i18n' ) filename = ( prefix + u'/test-view-car\xe1cter-internacional' ) bytestring = content . encode ( encoding ) try : f = cluster . fs . open ( filename , 'w' ) f . write ( bytestring ) f . close ( ) response = c . get ( ( '/filebrowser/view=%s?encoding=%s' % ( filename , encoding ) ) ) assert_equal ( response . context [ 'view' ] [ 'contents' ] , content ) response = c . get ( ( '/filebrowser/view=%s?encoding=%s&end=8&begin=1' % ( filename , encoding ) ) ) assert_equal ( response . context [ 'view' ] [ 'contents' ] , unicode ( bytestring [ 0 : 8 ] , encoding , errors = 'replace' ) ) finally : cleanup_file ( cluster , filename )
write the content in the given encoding directly into the filesystem .