Advertisement
gravgun

CCM Utf-8 test

Jun 20th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import random, sys
  3. def get_random_unicode(length):
  4.     include_ranges = [
  5.         ( 0x0021, 0x0021 ),
  6.         ( 0x0023, 0x0026 ),
  7.         ( 0x0028, 0x007E ),
  8.         ( 0x00A1, 0x00AC ),
  9.         ( 0x00AE, 0x00FF ),
  10.         ( 0x0100, 0x017F ),
  11.         ( 0x0180, 0x024F ),
  12.         ( 0x2C60, 0x2C7F ),
  13.         ( 0x16A0, 0x16F0 ),
  14.         ( 0x0370, 0x0377 ),
  15.         ( 0x037A, 0x037E ),
  16.         ( 0x0384, 0x038A ),
  17.         ( 0x038C, 0x038C ),
  18.         ( 0x30A0, 0x30FF ), #Katakana
  19.         ( 0x3041, 0x3096 ), #Hiragana
  20.         # Removed, these are huge ranges and spams the generator, making 99% of the text
  21.         #( 0x4E00, 0x9FBB ), #CJK UI
  22.         #( 0x3400, 0x4DB5 ), #CKJ UI ext 1
  23.         #( 0xAC00, 0xD7A3 ) #Hangul (Korean)
  24.     ]
  25.     alphabet = [
  26.         chr(code_point) for current_range in include_ranges
  27.             for code_point in range(current_range[0], current_range[1] + 1)
  28.     ]
  29.     return ''.join(random.choice(alphabet) for i in range(length))
  30.  
  31. print(get_random_unicode(int(sys.argv[1])))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement