Révision 3396

TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/txt/ListEncodingsMacro.groovy (revision 3396)
1
// Copyright © 2022 ENS Lyon
2
// Licensed under the terms of the GNU General Public License version 3 (http://www.gnu.org/licenses/gpl-3.0.html)
3
// @author sheiden
4

  
5
// STANDARD DECLARATIONS
6
package org.txm.macro.txt
7

  
8
import java.nio.charset.Charset
9

  
10
def charsets = Charset.availableCharsets()
11
def encodings = charsets.keySet()
12

  
13
def encodingsN = 0
14
println "== Character Encodings ==\n\n"+sprintf("%-15s (", "*Name*")+"*Alias names*)\n"
15
encodings.each { e ->
16
	charset = charsets.get(e)
17
	encodingsN++
18
	if (charset.canEncode()) {
19
		print sprintf("%-15s (", e)
20
		first = true
21
		charset.aliases().each { a ->
22
			if (!first) print ", "
23
			first = false
24
			print a
25
		}
26
		println ")"
27
	}
28
}
29
println encodingsN+" encodings."
30

  

Formats disponibles : Unified diff