Here is a function that will convert a 128-bit unsigned int into an IPv6 address with the correct (compressed) IPv6 formatting.
:
, , (nUInt128), 128- int. 8 (:: 1) , 136- (ColdFusion/Java, , ints). 128- , Java 16 , java.net.Inet6Address.getAddress(), . , ColdFusion 16 , java.net.Inet6Address.getAddress(). , , , . ColdFusion/Java - []. Back-fill , , 136- int.
<cffunction name="UInt128ToIPv6" returntype="string" output="no" access="public" hint="returns IPv6 address for uint128 number">
<cfargument name="nUInt128" type="numeric" required="yes" hint="uint128 to convert to ipv6 address">
<cfif arguments.nUInt128 EQ 0>
<cfreturn "">
</cfif>
<cftry>
<cfset local['javaMathBigInteger'] = CreateObject("java", "java.math.BigInteger").init(arguments.nUInt128)>
<cfset local['JavaNetInet6Address'] = CreateObject("java", "java.net.Inet6Address")>
<cfset local['arrBytes'] = local.javaMathBigInteger.toByteArray()>
<cfset local['arrFixedBytes'] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]>
<cfif arrayLen(local.arrBytes) NEQ 16>
<cfset local['nFixedIndex'] = 16>
<cfset local['nBytesIndex'] = arrayLen(local.arrBytes)>
<cfloop condition="local.nFixedIndex NEQ 0 && local.nBytesIndex NEQ 0">
<cfset local.arrFixedBytes[local.nFixedIndex] = local.arrBytes[local.nBytesIndex]>
<cfset local.nFixedIndex-->
<cfset local.nBytesIndex-->
</cfloop>
</cfif>
<cfif arrayLen(local.arrBytes) NEQ 16>
<cfset local['vcIPv6'] = local.JavaNetInet6Address.getByAddress(local.arrFixedBytes).getHostAddress()>
<cfelse>
<cfset local['vcIPv6'] = local.JavaNetInet6Address.getByAddress(local.javaMathBigInteger.toByteArray()).getHostAddress()>
</cfif>
<cfcatch type="any">
<cfset local['vcIPv6'] = "">
</cfcatch>
</cftry>
<cfreturn formatIPv6(vcIPv6 = local.vcIPv6)>
</cffunction>
formatIPv6(), .
<cffunction name="formatIPv6" returntype="string" output="yes" access="public" hint="returns a compressed ipv6 address">
<cfargument name="vcIPv6" type="string" required="yes" hint="IPv6 address">
<cfreturn reReplace(reReplace(LCase(arguments.vcIPv6), "(:|^)(0{0,3})([1-9a-f]*)", "\1\3", "all"), "(^|:)[0|:]+:", "::", "all")>
</cffunction>
/, .