<%@page import="org.openisis.*,java.io.IOException,java.util.Date,java.util.Iterator,java.net.URLEncoder" contentType="text/html;charset=UTF-8"%><%! static final String EMPTY = ""; static Db db; static String dberr = EMPTY; static { try { String[] args = new String[] { "-v", "9", "-encoding", "UTF-8", "-format", "aligned" }; db = Db.open( "/var/db/come2uni/come2uni", args ); if ( db instanceof NativeDb ) System.err.println( "db.db = "+((NativeDb)db).db ); } catch (IOException e) { dberr = e.toString(); } }; static String NV ( String x ) { return null==x ? EMPTY : x; } static int ROWS = 30; // number of rows to show at once static String vif ( String pre, Rec r, int t, String post ) { StringBuffer ret = null; int l = r.getLen(); for ( int i=0; i<% String search = NV( request.getParameter( "search" ) ); // brute force ... search = new String(search.getBytes("ISO-8859-1"), "UTF-8"); int off = 0; int rows = ROWS; try { off = Integer.parseInt( request.getParameter( "off" ) ); } catch ( Exception e ) {} try { rows = Integer.parseInt( request.getParameter( "rows" ) ); } catch ( Exception e ) {} int[] set = (int[])session.getAttribute( "set" ); %> OpenIsis unicode demo <%= dberr %>
<%-- method="POST" enctype="multipart/form-data" buys us nothing -- the ;charset=UTF-8 is parsed by newer tomcat, but not transmitted by Mozilla, so we have to do conversion manually anyway --%> as prefix rows at once
show index terms, not records
text excerpts are from the invitation to the Tenth International Unicode Conference.

<% if ( EMPTY != search ) { if ( null != request.getParameter( "terms" ) ) { Iterator t = db.terms( search ); while ( t.hasNext() ) { String s = (String)t.next(); if ( 0 == s.length() ) continue; String u = URLEncoder.encode( new String(s.getBytes("UTF-8"), "ISO-8859-1") ); %> <%=s%>
<% } %> <% return; } // list terms long then = (new Date()).getTime(); int mode = null==request.getParameter( "prefix" ) ? 0 : Db.QRY_KEYPF; int[] nset = db.search( search, mode ); long now = (new Date()).getTime(); if ( null == nset ) { %> sorry, no results for <%=search%> <% session.removeAttribute( "set" ); return; } else { %> got <%=nset.length%> rows for <%=search%> in <%= 0==mode ? "word" : "prefix" %> mode in <%=(now - then)/1000.%> seconds.
<% set = nset; session.setAttribute( "set", set ); } } // EMPTY != search if ( null == set ) return; if ( 0 < off ) { int boff = off-rows; if ( boff < 0 ) boff = 0; %> <<rows <%=boff+1%> to <%=boff+rows%> <% } int end = off + rows; if ( end >= set.length ) end = set.length; else { %> rows <%=end+1%> to <%=end+rows%>>> <% } %>

rows <%=off+1%> to <%=end%>

<%-- start output --%> <% for ( int i=off; i <% } // for rows %>
<%=name%>
lang=<%=lang%>><%=head%>
lang=<%=lang%>> <%=body%>