Advertisement
12Me21

that was not fucking 2 minutes you fucking liar

Jan 20th, 2017
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. OPTION BASE 0
  2. INPUT "text file in current folder: ", name$
  3. name$ = _CWD$ + "\" + name$
  4. OPEN name$ FOR BINARY AS #1
  5. size = LOF(1)
  6. PRINT size
  7.  
  8. DIM bytes(size) AS _UNSIGNED _BYTE
  9. DIM char AS _UNSIGNED _BYTE
  10.  
  11. GET #1, , bytes()
  12.  
  13. length = size
  14. FOR I = 0 TO size - 1
  15. char = bytes(I)
  16.  
  17. IF char >= 128 THEN
  18. length = length + 1
  19. END IF
  20. NEXT
  21. spot = 0
  22. DIM newbytes(length) AS _UNSIGNED _BYTE
  23. FOR I = 0 TO size - 1
  24. char = bytes(I)
  25. IF char < 128 THEN
  26. newbytes(spot) = char
  27. PRINT char; " became "; char; "!"
  28. END IF
  29. IF char >= 128 THEN
  30. PRINT char; " became "; char \ 64 + &B11000000; " and "; char MOD 64 + &B10000000
  31. newbytes(spot) = char \ 64 + &B11000000
  32. spot = spot + 1
  33. newbytes(spot) = char MOD 64 + &B10000000
  34. END IF
  35. spot = spot + 1
  36. NEXT
  37. PUT #1, 1, newbytes()
  38.  
  39. FUNCTION Bin$ (number&)
  40. IF number& = 0 THEN EXIT FUNCTION
  41. DO
  42. remain% = ABS(number& MOD 2) ' remainder is used to create binary number
  43. number& = number& \ 2 ' move up one exponent of 2 with integer division
  44. Bin2$ = LTRIM$(STR$(remain%)) ' make remainder a string number
  45. Binary$ = Bin2$ + Binary$ ' add remainder to binary number
  46. LOOP UNTIL number& = 0
  47. Bin$ = Binary$ 'binary result
  48. END SUB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement