// Swap the Hebrew characters of a string
// Input:
// hdc - device context (can be GetDC(NULL) for screen)
// s - the string to be fixed
// bRtlParagraph - TRUE for a Hebrew paragraph, FALSE for English paragraph (with Hebrew words inside)
void ReorderRtlCharacters ( HDC hdc, char *s, BOOL bRtlParagraph )
{
GCP_RESULTS gcp ;
LPSTR lpClass ;
unsigned l = lstrlen(s) ;
lpClass = (LPSTR)GlobalAlloc(GPTR, l + 3 );
ZeroMemory( lpClass, sizeof(l + 3)) ;
ZeroMemory( &gcp, sizeof(gcp)) ;
gcp.lStructSize = sizeof(gcp) ;
gcp.lpOutString = s ;
gcp.nGlyphs = l ;
if ( bRtlParagraph )
lpClass[0] = GCPCLASS_PREBOUNDRTL | GCPCLASS_POSTBOUNDRTL ;
gcp.lpClass = lpClass ;
GetCharacterPlacement(hdc, s, l, 0, &gcp, GCP_REORDER | GCP_CLASSIN ) ;
GlobalFree(lpClass);
}