mirror of https://github.com/apache/lucene.git
49 lines
1.9 KiB
Groovy
49 lines
1.9 KiB
Groovy
|
import com.ibm.icu.text.UnicodeSet;
|
||
|
import com.ibm.icu.lang.UCharacter
|
||
|
import com.ibm.icu.util.VersionInfo
|
||
|
import java.nio.file.*
|
||
|
|
||
|
def outputFile = Paths.get(args[0])
|
||
|
|
||
|
StringBuilder sb = new StringBuilder()
|
||
|
[ "Emoji", "Emoji_Modifier", "Emoji_Modifier_Base", "Extended_Pictographic" ].each { setName ->
|
||
|
UnicodeSet set = new UnicodeSet("[:" + setName + ":]")
|
||
|
sb.append(setName + " = [")
|
||
|
for (UnicodeSet.EntryRange range : set.ranges()) {
|
||
|
if (range.codepoint == range.codepointEnd) {
|
||
|
sb.append("\\u{" + Integer.toHexString(range.codepoint).toUpperCase(Locale.ROOT) + "}")
|
||
|
} else {
|
||
|
sb.append("\\u{" + Integer.toHexString(range.codepoint).toUpperCase(Locale.ROOT) + "}-\\u{" + Integer.toHexString(range.codepointEnd).toUpperCase(Locale.ROOT) + "}")
|
||
|
}
|
||
|
}
|
||
|
sb.append("]\n")
|
||
|
}
|
||
|
|
||
|
def icuVersion = VersionInfo.ICU_VERSION.toString()
|
||
|
def unicodeVersion = UCharacter.getUnicodeVersion().toString()
|
||
|
|
||
|
def code = """
|
||
|
// DO NOT EDIT THIS FILE! Use "gradlew generateEmojiProperties" to recreate.
|
||
|
// The data was generated using ICU4J v${icuVersion}, unicode version: ${unicodeVersion}.
|
||
|
|
||
|
/*
|
||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||
|
* contributor license agreements. See the NOTICE file distributed with
|
||
|
* this work for additional information regarding copyright ownership.
|
||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||
|
* (the "License"); you may not use this file except in compliance with
|
||
|
* the License. You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*/
|
||
|
|
||
|
${sb.toString()}
|
||
|
"""
|
||
|
outputFile.setText(code, "UTF-8")
|