📄 base64test.groovy
字号:
class Base64Test extends GroovyTestCase { void testCodec() { def testString ="§1234567890-=±!@£\$%^&*()_+qwertyuiop[]QWERTYUIOP{}asdfghjkl;'\\ASDFGHJKL:\"|`zxcvbnm,./~ZXCVBNM<>?\u0003\u00ff\u00f0\u000f" // get a byte array using the least significant eigth bits of each caharacter def testBytes = testString.getBytes("ISO-8859-1") // turn the bytes back into a string for later comparison testString = new String(testBytes, "ISO-8859-1") // encode the bytes as base64. This produces a Writable object convert it to a String def encodedBytes = testBytes.encodeBase64().toString() // decode the base64 back to a byte array def decodedBytes = encodedBytes.decodeBase64() // turn the byte array back to a String for caomparison def decodedString = new String(decodedBytes, "ISO-8859-1") assert decodedString.equals(testString) }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -